diff --git a/packages/lib-common/src/references/pairedDelimiterReferences.ts b/packages/lib-common/src/references/pairedDelimiterReferences.ts index 82f6e1a2f00..44f59605e5e 100644 --- a/packages/lib-common/src/references/pairedDelimiterReferences.ts +++ b/packages/lib-common/src/references/pairedDelimiterReferences.ts @@ -1,147 +1,243 @@ import type { SpeakableSurroundingPairName } from "../types/SpokenFormType"; import type { SpokenFormReference } from "./ReferenceEntry"; +export type IndividualDelimiterText = string | string[]; + +export interface PairedDelimiterLanguageOverride { + matchingDelimiters?: readonly [ + IndividualDelimiterText, + IndividualDelimiterText, + ]; + isSingleLine?: boolean; +} + export interface PairedDelimiterReference extends SpokenFormReference { name: string; defaultSpokenForm: string; + index: number | null; + + /** Whether both delimiters must occur on the same line. */ + isSingleLine: boolean; + + /** The canonical delimiters used when inserting a surrounding pair. */ delimiters: readonly [string, string] | null; - selectable: boolean; - referenceIndex: number | null; + + /** + * The delimiters recognized when finding a surrounding pair. A non-null + * value indicates that the pair is selectable. Empty arrays indicate that + * matching is provided by language overrides or complex-pair expansion. + */ + matchingDelimiters: + | readonly [IndividualDelimiterText, IndividualDelimiterText] + | null; + + /** Language-specific overrides for matching behavior. */ + languageOverrides?: Readonly>; } export const pairedDelimiterReferences = { + doubleQuotes: { + name: "double quotes", + defaultSpokenForm: "quad", + index: 0, + isSingleLine: true, + delimiters: ['"', '"'], + matchingDelimiters: ['"', '"'], + languageOverrides: { + lua: { + // FIXME: Add special double square brackets + // see https://github.com/cursorless-dev/cursorless/pull/2012#issuecomment-1808214409 + // see also https://github.com/cursorless-dev/cursorless/issues/1812#issuecomment-1691493746 + matchingDelimiters: [ + ['"', "[["], + ['"', "]]"], + ], + isSingleLine: false, + }, + ruby: { + isSingleLine: false, + }, + clojure: { + isSingleLine: false, + }, + csharp: { + matchingDelimiters: [ + ['@"', '"'], + ['"', '"'], + ], + isSingleLine: false, + }, + }, + }, + singleQuotes: { + name: "single quotes", + defaultSpokenForm: "twin", + index: 1, + isSingleLine: true, + delimiters: ["'", "'"], + matchingDelimiters: ["'", "'"], + languageOverrides: { + nix: { + matchingDelimiters: ["''", "''"], + isSingleLine: false, + }, + }, + }, + backtickQuotes: { + name: "backtick quotes", + defaultSpokenForm: "skis", + index: 2, + isSingleLine: false, + delimiters: ["`", "`"], + matchingDelimiters: ["`", "`"], + }, + parentheses: { + name: "parentheses", + defaultSpokenForm: "round", + index: 3, + isSingleLine: false, + delimiters: ["(", ")"], + matchingDelimiters: [["(", "$("], ")"], + }, curlyBrackets: { name: "curly brackets", defaultSpokenForm: "curly", + index: 4, + isSingleLine: false, delimiters: ["{", "}"], - selectable: true, - referenceIndex: 4, + matchingDelimiters: [["{", "${"], "}"], + }, + squareBrackets: { + name: "square brackets", + defaultSpokenForm: "box", + index: 5, + isSingleLine: false, + delimiters: ["[", "]"], + matchingDelimiters: ["[", "]"], }, angleBrackets: { name: "angle brackets", defaultSpokenForm: "diamond", + index: 6, + isSingleLine: false, delimiters: ["<", ">"], - selectable: true, - referenceIndex: 6, + matchingDelimiters: [ + ["", "/>"], + ], }, escapedDoubleQuotes: { name: "escaped double quotes", defaultSpokenForm: "escaped quad", + index: 7, + isSingleLine: true, delimiters: [String.raw`\"`, String.raw`\"`], - selectable: true, - referenceIndex: 7, + matchingDelimiters: [String.raw`\"`, String.raw`\"`], }, escapedSingleQuotes: { name: "escaped single quotes", defaultSpokenForm: "escaped twin", + index: 8, + isSingleLine: true, delimiters: [String.raw`\'`, String.raw`\'`], - selectable: true, - referenceIndex: 8, + matchingDelimiters: [String.raw`\'`, String.raw`\'`], }, escapedParentheses: { name: "escaped parentheses", defaultSpokenForm: "escaped round", + index: 9, + isSingleLine: false, delimiters: [String.raw`\(`, String.raw`\)`], - selectable: true, - referenceIndex: 9, + matchingDelimiters: [String.raw`\(`, String.raw`\)`], + }, + whitespace: { + name: "space", + defaultSpokenForm: "void", + index: 10, + isSingleLine: false, + delimiters: [" ", " "], + matchingDelimiters: null, + }, + any: { + name: "any", + defaultSpokenForm: "pair", + index: 11, + isSingleLine: false, + delimiters: null, + matchingDelimiters: [[], []], }, escapedSquareBrackets: { name: "escaped square brackets", defaultSpokenForm: "escaped box", + index: null, + isSingleLine: false, delimiters: [String.raw`\[`, String.raw`\]`], - selectable: true, - referenceIndex: null, - }, - doubleQuotes: { - name: "double quotes", - defaultSpokenForm: "quad", - delimiters: ['"', '"'], - selectable: true, - referenceIndex: 0, - }, - parentheses: { - name: "parentheses", - defaultSpokenForm: "round", - delimiters: ["(", ")"], - selectable: true, - referenceIndex: 3, - }, - backtickQuotes: { - name: "backtick quotes", - defaultSpokenForm: "skis", - delimiters: ["`", "`"], - selectable: true, - referenceIndex: 2, - }, - squareBrackets: { - name: "square brackets", - defaultSpokenForm: "box", - delimiters: ["[", "]"], - selectable: true, - referenceIndex: 5, - }, - singleQuotes: { - name: "single quotes", - defaultSpokenForm: "twin", - delimiters: ["'", "'"], - selectable: true, - referenceIndex: 1, + matchingDelimiters: [String.raw`\[`, String.raw`\]`], }, tripleDoubleQuotes: { name: "triple double quotes", defaultSpokenForm: "triple quad", - delimiters: ['"""', '"""'], - selectable: true, - referenceIndex: null, - disabledByDefault: true, private: true, + disabledByDefault: true, + index: null, + isSingleLine: false, + delimiters: ['"""', '"""'], + matchingDelimiters: [[], []], + languageOverrides: { + python: { + matchingDelimiters: ['"""', '"""'], + }, + ruby: { + matchingDelimiters: ["%Q(", ")"], + }, + }, }, tripleSingleQuotes: { name: "triple single quotes", defaultSpokenForm: "triple twin", - delimiters: ["'''", "'''"], - selectable: true, - referenceIndex: null, - disabledByDefault: true, private: true, + disabledByDefault: true, + index: null, + isSingleLine: false, + delimiters: ["'''", "'''"], + matchingDelimiters: [[], []], + languageOverrides: { + python: { + matchingDelimiters: ["'''", "'''"], + }, + }, }, tripleBacktickQuotes: { name: "triple backtick quotes", defaultSpokenForm: "triple skis", - delimiters: ["```", "```"], - selectable: true, - referenceIndex: null, - disabledByDefault: true, private: true, - }, - any: { - name: "any", - defaultSpokenForm: "pair", - delimiters: null, - selectable: true, - referenceIndex: 11, + disabledByDefault: true, + index: null, + isSingleLine: false, + delimiters: ["```", "```"], + matchingDelimiters: [[], []], + languageOverrides: { + markdown: { + matchingDelimiters: ["```", "```"], + }, + }, }, string: { name: "string", defaultSpokenForm: "string", + index: null, + isSingleLine: false, delimiters: null, - selectable: true, - referenceIndex: null, - }, - whitespace: { - name: "space", - defaultSpokenForm: "void", - delimiters: [" ", " "], - selectable: false, - referenceIndex: 10, + matchingDelimiters: [[], []], }, collectionBoundary: { name: "collection boundary", defaultSpokenForm: "collection boundary", - delimiters: null, - selectable: true, - referenceIndex: null, - disabledByDefault: true, private: true, + disabledByDefault: true, + index: null, + isSingleLine: false, + delimiters: null, + matchingDelimiters: [[], []], }, } satisfies Record; diff --git a/packages/lib-common/src/references/scopeReferences.ts b/packages/lib-common/src/references/scopeReferences.ts index da4848dac54..682707edb2d 100644 --- a/packages/lib-common/src/references/scopeReferences.ts +++ b/packages/lib-common/src/references/scopeReferences.ts @@ -1,4 +1,9 @@ -import type { ScopeTypeType } from "../types/command/PartialTargetDescriptor.types"; +import type { + ScopeType, + ScopeTypeType, + SimpleScopeTypeType, +} from "../types/command/PartialTargetDescriptor.types"; +import { simpleScopeTypeTypes } from "../types/command/PartialTargetDescriptor.types"; import { EVERY, ITEM, @@ -23,6 +28,12 @@ import { ordinalDefaultSpokenForms } from "./spokenForms/numberDefaultSpokenForm interface ScopeReferenceEntry extends ReferenceEntry { /** Whether the scope is defined on a per-language basis. */ isLanguageSpecific: boolean; + + /** Whether the scope is implemented by a dedicated modifier. */ + isPseudoScope?: boolean; + + /** The delimiter to use when inserting another instance of the scope. */ + defaultInsertionDelimiter?: string; } const DEFAULT_PATTERN = VAR_SPOKEN_FORM; @@ -39,10 +50,10 @@ const FOURTH = ordinalDefaultSpokenForms[4]; export const scopeReferences = { // Group: text character: { - isLanguageSpecific: false, name: "Character", group: { id: "text", index: 0 }, defaultSpokenForm: "char", + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -58,11 +69,11 @@ export const scopeReferences = { ], }, word: { - isLanguageSpecific: false, name: "Sub token word", group: { id: "text", index: 1 }, defaultSpokenForm: "sub", legacySpokenForms: ["word"], + isLanguageSpecific: false, description: "Selects an individual word-like component within a camelCase, snake_case, or similarly structured token. It can be combined with ordinal and range modifiers to select one or more components.", syntaxes: [ @@ -85,10 +96,10 @@ export const scopeReferences = { ], }, token: { - isLanguageSpecific: false, name: "Token", group: { id: "text", index: 2 }, defaultSpokenForm: "token", + isLanguageSpecific: false, description: "Expands the input to the nearest containing token. Without an explicit mark, it uses the token adjacent to the cursor or containing the current selection.", syntaxes: [ @@ -106,10 +117,10 @@ export const scopeReferences = { ], }, identifier: { - isLanguageSpecific: false, name: "Identifier", group: { id: "text", index: 3 }, defaultSpokenForm: "identifier", + isLanguageSpecific: false, description: `Like a token, but limited to text that can act as an identifier, such as \`foo\`, \`fooBar\`, or \`foo_bar\`; operators such as \`.\`, \`=\`, and \`+=\` are excluded. This scope is useful with ordinals such as \`${LAST} identifier\`.`, syntaxes: [ { @@ -127,10 +138,10 @@ export const scopeReferences = { ], }, sentence: { - isLanguageSpecific: false, name: "Sentence", group: { id: "text", index: 4 }, defaultSpokenForm: "sentence", + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -147,10 +158,10 @@ export const scopeReferences = { ], }, line: { - isLanguageSpecific: false, name: "Line", group: { id: "text", index: 5 }, defaultSpokenForm: LINE, + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -166,10 +177,10 @@ export const scopeReferences = { ], }, fullLine: { - isLanguageSpecific: false, name: "Full line", group: { id: "text", index: 6 }, defaultSpokenForm: "full line", + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -185,10 +196,10 @@ export const scopeReferences = { ], }, paragraph: { - isLanguageSpecific: false, name: "Paragraph", group: { id: "text", index: 7 }, defaultSpokenForm: "block", + isLanguageSpecific: false, description: "Expands above and below the input through contiguous nonempty lines, stopping at empty lines.", syntaxes: [ @@ -206,10 +217,10 @@ export const scopeReferences = { ], }, boundedParagraph: { - isLanguageSpecific: false, name: "Bounded paragraph", group: { id: "text", index: 8 }, defaultSpokenForm: "short block", + isLanguageSpecific: false, description: 'Like `"block"`, but also stops at the boundary of a surrounding delimiter pair, so the selection does not escape the pair containing the input target.', syntaxes: [ @@ -227,10 +238,10 @@ export const scopeReferences = { ], }, document: { - isLanguageSpecific: false, name: "Document", group: { id: "text", index: 9 }, defaultSpokenForm: "file", + isLanguageSpecific: false, description: "The entire document, from the first to the last character.", syntaxes: [ { @@ -247,10 +258,10 @@ export const scopeReferences = { ], }, nonWhitespaceSequence: { - isLanguageSpecific: false, name: "Non-whitespace sequence", group: { id: "text", index: 10 }, defaultSpokenForm: "paint", + isLanguageSpecific: false, description: "Expands forward and backward from the input through adjacent non-whitespace characters.", syntaxes: [ @@ -268,10 +279,10 @@ export const scopeReferences = { ], }, boundedNonWhitespaceSequence: { - isLanguageSpecific: false, name: "Bounded non-whitespace sequence", group: { id: "text", index: 11 }, defaultSpokenForm: "short paint", + isLanguageSpecific: false, description: 'Like `"paint"`, but expansion also stops at a delimiter pair that surrounds the input target. Delimiter pairs that do not surround the original target do not stop expansion.', syntaxes: [ @@ -291,10 +302,10 @@ export const scopeReferences = { ], }, url: { - isLanguageSpecific: false, name: "URL", group: { id: "text", index: 12 }, defaultSpokenForm: "link", + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -310,9 +321,9 @@ export const scopeReferences = { ], }, surroundingPair: { - isLanguageSpecific: false, name: "Surrounding pair", group: { id: "text", index: 13 }, + isLanguageSpecific: false, description: `Expands the input to the nearest containing [paired delimiters](../paired-delimiters.md) and their contents. Use the [interior-only](../modifiers/interiorOnly.mdx) or [exclude-interior](../modifiers/excludeInterior.mdx) modifiers to select only the contents or only the delimiters. When an opening and closing delimiter use the same character and no parse-tree information is available, Cursorless treats the first occurrence on each line as an opening delimiter and alternates subsequent occurrences between closing and opening delimiters.`, @@ -331,10 +342,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, glyph: { - isLanguageSpecific: false, name: "Glyph", group: { id: "text", index: 14 }, defaultSpokenForm: "glyph", + isLanguageSpecific: false, syntaxes: [ { pattern: `${VAR_SPOKEN_FORM} ${VAR_CHARACTER}`, @@ -352,10 +363,11 @@ When an opening and closing delimiter use the same character and no parse-tree i // Group: documentHierarchy part: { - isLanguageSpecific: true, name: "Part", group: { id: "documentHierarchy", index: 0 }, defaultSpokenForm: "part", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -371,10 +383,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, chapter: { - isLanguageSpecific: true, name: "Chapter", group: { id: "documentHierarchy", index: 1 }, defaultSpokenForm: "chapter", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -390,10 +403,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, subSection: { - isLanguageSpecific: true, name: "Subsection", group: { id: "documentHierarchy", index: 2 }, defaultSpokenForm: "subsection", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -409,10 +423,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, subSubSection: { - isLanguageSpecific: true, name: "Subsubsection", group: { id: "documentHierarchy", index: 3 }, defaultSpokenForm: "subsubsection", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -428,10 +443,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, namedParagraph: { - isLanguageSpecific: true, name: "Named paragraph", group: { id: "documentHierarchy", index: 4 }, defaultSpokenForm: "paragraph", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -447,10 +463,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, subParagraph: { - isLanguageSpecific: true, name: "Subparagraph", group: { id: "documentHierarchy", index: 5 }, defaultSpokenForm: "subparagraph", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -466,10 +483,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, environment: { - isLanguageSpecific: true, name: "Environment", group: { id: "documentHierarchy", index: 6 }, defaultSpokenForm: "environment", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -487,10 +505,10 @@ When an opening and closing delimiter use the same character and no parse-tree i // Group: collections list: { - isLanguageSpecific: true, name: "List", group: { id: "collections", index: 0 }, defaultSpokenForm: "list", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -506,10 +524,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, map: { - isLanguageSpecific: true, name: "Map", group: { id: "collections", index: 1 }, defaultSpokenForm: "map", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -525,10 +543,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, collectionItem: { - isLanguageSpecific: true, name: "Collection item", group: { id: "collections", index: 2 }, defaultSpokenForm: ITEM, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -544,10 +563,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, collectionKey: { - isLanguageSpecific: true, name: "Collection key", group: { id: "collections", index: 3 }, defaultSpokenForm: "key", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -565,10 +584,10 @@ When an opening and closing delimiter use the same character and no parse-tree i // Group: functions argumentOrParameter: { - isLanguageSpecific: true, name: "Argument or parameter", group: { id: "functions", index: 0 }, defaultSpokenForm: "arg", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -584,10 +603,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, argumentList: { - isLanguageSpecific: true, name: "Argument list", group: { id: "functions", index: 1 }, defaultSpokenForm: "arg list", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -603,10 +622,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, anonymousFunction: { - isLanguageSpecific: true, name: "Anonymous function", group: { id: "functions", index: 2 }, defaultSpokenForm: "lambda", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -622,10 +642,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, namedFunction: { - isLanguageSpecific: true, name: "Named function", group: { id: "functions", index: 3 }, defaultSpokenForm: "funk", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -641,10 +662,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, functionName: { - isLanguageSpecific: true, name: "Function name", group: { id: "functions", index: 4 }, defaultSpokenForm: "funk name", + isLanguageSpecific: true, + isPseudoScope: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -660,10 +682,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, functionCall: { - isLanguageSpecific: true, name: "Function call", group: { id: "functions", index: 5 }, defaultSpokenForm: "call", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -679,10 +701,10 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, functionCallee: { - isLanguageSpecific: true, name: "Function callee", group: { id: "functions", index: 6 }, defaultSpokenForm: "callee", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -700,10 +722,11 @@ When an opening and closing delimiter use the same character and no parse-tree i // Group: objects class: { - isLanguageSpecific: true, name: "Class", group: { id: "objects", index: 0 }, defaultSpokenForm: "class", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -719,10 +742,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, className: { - isLanguageSpecific: true, name: "Class name", group: { id: "objects", index: 1 }, defaultSpokenForm: "class name", + isLanguageSpecific: true, + isPseudoScope: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -738,10 +762,11 @@ When an opening and closing delimiter use the same character and no parse-tree i ], }, instance: { - isLanguageSpecific: true, name: "Instance", group: { id: "objects", index: 2 }, defaultSpokenForm: "instance", + isLanguageSpecific: true, + isPseudoScope: true, description: `Searches for occurrences of the input target's text. Instance matching preserves the target's scope type, so an instance of a token only matches complete tokens rather than substrings within larger tokens; apply [\`"just"\`](../modifiers/toRawSelection.mdx) to match the raw text instead. For a range target, the entire range becomes the search text. Without an explicit mark, Cursorless uses the token touching the cursor. Use [\`"from"\`](../actions/setInstanceReference.mdx) to restrict the search region or choose its starting point.`, @@ -772,10 +797,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, name: { - isLanguageSpecific: true, name: "Name", group: { id: "objects", index: 3 }, defaultSpokenForm: "name", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -792,10 +817,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, attribute: { - isLanguageSpecific: true, name: "Attribute", group: { id: "objects", index: 4 }, defaultSpokenForm: "attribute", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -811,10 +836,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, type: { - isLanguageSpecific: true, name: "Type", group: { id: "objects", index: 5 }, defaultSpokenForm: "type", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -830,10 +855,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, value: { - isLanguageSpecific: true, name: "Value", group: { id: "objects", index: 6 }, defaultSpokenForm: "value", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -852,10 +877,11 @@ For a range target, the entire range becomes the search text. Without an explici // Group: statements statement: { - isLanguageSpecific: true, name: "Statement", group: { id: "statements", index: 0 }, defaultSpokenForm: STATEMENT, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -872,10 +898,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, branch: { - isLanguageSpecific: true, name: "Branch", group: { id: "statements", index: 1 }, defaultSpokenForm: "branch", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -892,10 +919,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, ifStatement: { - isLanguageSpecific: true, name: "If statement", group: { id: "statements", index: 2 }, defaultSpokenForm: "if state", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -911,10 +939,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, condition: { - isLanguageSpecific: true, name: "Condition", group: { id: "statements", index: 3 }, defaultSpokenForm: "condition", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -930,10 +958,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, comment: { - isLanguageSpecific: true, name: "Comment", group: { id: "statements", index: 4 }, defaultSpokenForm: "comment", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -949,10 +978,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, command: { - isLanguageSpecific: true, name: "Command", group: { id: "statements", index: 5 }, defaultSpokenForm: "command", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -969,10 +998,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, regularExpression: { - isLanguageSpecific: true, name: "Regular expression", group: { id: "statements", index: 6 }, defaultSpokenForm: "regex", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -990,10 +1019,11 @@ For a range target, the entire range becomes the search text. Without an explici // Group: markup xmlElement: { - isLanguageSpecific: true, name: "XML element", group: { id: "markup", index: 0 }, defaultSpokenForm: "element", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1010,10 +1040,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, xmlStartTag: { - isLanguageSpecific: true, name: "XML start tag", group: { id: "markup", index: 1 }, defaultSpokenForm: "start tag", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1029,10 +1059,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, xmlEndTag: { - isLanguageSpecific: true, name: "XML end tag", group: { id: "markup", index: 2 }, defaultSpokenForm: "end tag", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1048,10 +1078,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, xmlBothTags: { - isLanguageSpecific: true, name: "XML both tags", group: { id: "markup", index: 3 }, defaultSpokenForm: "tags", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1068,10 +1098,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, selector: { - isLanguageSpecific: true, name: "Selector", group: { id: "markup", index: 4 }, defaultSpokenForm: "selector", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1087,10 +1117,10 @@ For a range target, the entire range becomes the search text. Without an explici ], }, unit: { - isLanguageSpecific: true, name: "Unit", group: { id: "markup", index: 5 }, defaultSpokenForm: "unit", + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1108,10 +1138,11 @@ For a range target, the entire range becomes the search text. Without an explici // Group: sections section: { - isLanguageSpecific: true, name: "Section", group: { id: "sections", index: 0 }, defaultSpokenForm: "section", + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1128,11 +1159,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelOne: { - isLanguageSpecific: true, name: "Section level one", group: { id: "sections", index: 1 }, defaultSpokenForm: "one section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1148,11 +1180,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelTwo: { - isLanguageSpecific: true, name: "Section level two", group: { id: "sections", index: 2 }, defaultSpokenForm: "two section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1168,11 +1201,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelThree: { - isLanguageSpecific: true, name: "Section level three", group: { id: "sections", index: 3 }, defaultSpokenForm: "three section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1188,11 +1222,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelFour: { - isLanguageSpecific: true, name: "Section level four", group: { id: "sections", index: 4 }, defaultSpokenForm: "four section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1208,11 +1243,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelFive: { - isLanguageSpecific: true, name: "Section level five", group: { id: "sections", index: 5 }, defaultSpokenForm: "five section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1228,11 +1264,12 @@ For a range target, the entire range becomes the search text. Without an explici ], }, sectionLevelSix: { - isLanguageSpecific: true, name: "Section level six", group: { id: "sections", index: 6 }, defaultSpokenForm: "six section", disabledByDefault: true, + isLanguageSpecific: true, + defaultInsertionDelimiter: "\n\n", syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1250,10 +1287,10 @@ For a range target, the entire range becomes the search text. Without an explici // Group: notebook notebookCell: { - isLanguageSpecific: false, name: "Notebook cell", group: { id: "notebook", index: 0 }, defaultSpokenForm: "cell", + isLanguageSpecific: false, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1271,11 +1308,11 @@ For a range target, the entire range becomes the search text. Without an explici // Group: private "private.fieldAccess": { - isLanguageSpecific: true, name: "Field access", group: { id: "private", index: 0 }, defaultSpokenForm: "access", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1291,11 +1328,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, string: { - isLanguageSpecific: true, name: "String", group: { id: "private", index: 1 }, defaultSpokenForm: "parse tree string", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1311,11 +1348,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, textFragment: { - isLanguageSpecific: true, name: "Text fragment", group: { id: "private", index: 2 }, defaultSpokenForm: "text fragment", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1331,11 +1368,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, disqualifyDelimiter: { - isLanguageSpecific: true, name: "Disqualify delimiter", group: { id: "private", index: 3 }, defaultSpokenForm: "disqualify delimiter", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1351,11 +1388,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, pairDelimiter: { - isLanguageSpecific: true, name: "Pair delimiter", group: { id: "private", index: 4 }, defaultSpokenForm: "pair delimiter", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1371,11 +1408,11 @@ For a range target, the entire range becomes the search text. Without an explici ], }, interior: { - isLanguageSpecific: true, name: "Interior", group: { id: "private", index: 5 }, defaultSpokenForm: "interior", private: true, + isLanguageSpecific: true, syntaxes: [ { pattern: DEFAULT_PATTERN, @@ -1391,19 +1428,38 @@ For a range target, the entire range becomes the search text. Without an explici ], }, surroundingPairInterior: { - isLanguageSpecific: false, name: "Surrounding pair interior", group: { id: "private", index: 6 }, private: true, + isLanguageSpecific: false, syntaxes: [], examples: [], }, customRegex: { - isLanguageSpecific: false, name: "Custom regex", group: { id: "private", index: 7 }, private: true, + isLanguageSpecific: false, syntaxes: [], examples: [], }, } as const satisfies Record; + +export const pseudoScopeTypeTypes = new Set( + simpleScopeTypeTypes.filter((scopeType) => { + const reference: ScopeReferenceEntry = scopeReferences[scopeType]; + return reference.isPseudoScope; + }), +); + +export function isPseudoScopeType(scopeType: ScopeType): boolean { + const reference: ScopeReferenceEntry = scopeReferences[scopeType.type]; + return reference.isPseudoScope ?? false; +} + +export function getDefaultInsertionDelimiter( + scopeType: SimpleScopeTypeType, +): string { + const reference: ScopeReferenceEntry = scopeReferences[scopeType]; + return reference.defaultInsertionDelimiter ?? " "; +} diff --git a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts index 8d627abcdc9..48fdcfb89e0 100644 --- a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts @@ -215,24 +215,12 @@ const simpleScopeTypeTypesSet = new Set(simpleScopeTypeTypes); export type SimpleScopeTypeType = (typeof simpleScopeTypeTypes)[number]; -export const pseudoScopeTypeTypes = new Set([ - "instance", - "className", - "functionName", -]); - export function isSimpleScopeType( scopeType: ScopeType, ): scopeType is SimpleScopeType { return (simpleScopeTypeTypesSet as Set).has(scopeType.type); } -export function isPseudoScopeType(scopeType: ScopeType): boolean { - return ( - isSimpleScopeType(scopeType) && pseudoScopeTypeTypes.has(scopeType.type) - ); -} - export interface SimpleScopeType { type: SimpleScopeTypeType; } diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts index f0a3d4d7009..c4d31b3b3b9 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts @@ -1,18 +1,12 @@ import type { ComplexSurroundingPairName, + IndividualDelimiterText, + PairedDelimiterReference, SimpleSurroundingPairName, } from "@cursorless/lib-common"; -import { unsafeKeys } from "@cursorless/lib-common"; - -type IndividualDelimiterText = string | string[]; +import { pairedDelimiterReferences, unsafeKeys } from "@cursorless/lib-common"; interface Options { - /** - * If true, then the delimiter pair can only be on a single line. We use this - * flag to save us searching the entire document when we're trying to - * determine whether an ambiguous delimiter is opening or closing. The most - * salient example is strings. - */ isSingleLine?: boolean; } @@ -22,73 +16,56 @@ type DelimiterMap = Record< | [IndividualDelimiterText, IndividualDelimiterText, Options] >; -// Note that the order here is important since we are creating a regex from the key order. -// For example triple quotes need to come before single quotes. -const delimiterToText: DelimiterMap = Object.freeze({ - angleBrackets: [ - ["", "/>"], - ], - curlyBrackets: [["{", "${"], "}"], - tripleBacktickQuotes: [[], []], - tripleDoubleQuotes: [[], []], - tripleSingleQuotes: [[], []], - doubleQuotes: ['"', '"', { isSingleLine: true }], - escapedDoubleQuotes: [String.raw`\"`, String.raw`\"`, { isSingleLine: true }], - escapedParentheses: [String.raw`\(`, String.raw`\)`], - escapedSquareBrackets: [String.raw`\[`, String.raw`\]`], - escapedSingleQuotes: [String.raw`\'`, String.raw`\'`, { isSingleLine: true }], - parentheses: [["(", "$("], ")"], - backtickQuotes: ["`", "`"], - singleQuotes: ["'", "'", { isSingleLine: true }], - squareBrackets: ["[", "]"], -}); - -// FIXME: Probably remove these as part of -// https://github.com/cursorless-dev/cursorless/issues/1812#issuecomment-1691493746 -const delimiterToTextOverrides: Record> = { - nix: { - singleQuotes: ["''", "''"], - }, +const matchingDelimiterMap = getMatchingDelimiterMap(undefined); +const matchingDelimiterMapCache = new Map(); - lua: { - // FIXME: Add special double square brackets - // see https://github.com/cursorless-dev/cursorless/pull/2012#issuecomment-1808214409 - // see also https://github.com/cursorless-dev/cursorless/issues/1812#issuecomment-1691493746 - doubleQuotes: [ - ['"', "[["], - ['"', "]]"], - ], - }, +function getMatchingDelimiterMap(languageId: string | undefined): DelimiterMap { + const getDefinition = (name: SimpleSurroundingPairName) => + getReferenceDelimiterDefinition(name, languageId); - python: { - tripleSingleQuotes: ["'''", "'''"], - tripleDoubleQuotes: ['"""', '"""'], - }, + // Note that the order here is important since we are creating a regex from the key order. + // For example triple quotes need to come before single quotes. + return Object.freeze({ + angleBrackets: getDefinition("angleBrackets"), + curlyBrackets: getDefinition("curlyBrackets"), + tripleBacktickQuotes: getDefinition("tripleBacktickQuotes"), + tripleDoubleQuotes: getDefinition("tripleDoubleQuotes"), + tripleSingleQuotes: getDefinition("tripleSingleQuotes"), + doubleQuotes: getDefinition("doubleQuotes"), + escapedDoubleQuotes: getDefinition("escapedDoubleQuotes"), + escapedParentheses: getDefinition("escapedParentheses"), + escapedSquareBrackets: getDefinition("escapedSquareBrackets"), + escapedSingleQuotes: getDefinition("escapedSingleQuotes"), + parentheses: getDefinition("parentheses"), + backtickQuotes: getDefinition("backtickQuotes"), + singleQuotes: getDefinition("singleQuotes"), + squareBrackets: getDefinition("squareBrackets"), + }); +} - markdown: { - tripleBacktickQuotes: ["```", "```"], - }, +function getReferenceDelimiterDefinition( + name: SimpleSurroundingPairName, + languageId: string | undefined, +): DelimiterMap[SimpleSurroundingPairName] { + const reference: PairedDelimiterReference = pairedDelimiterReferences[name]; + const languageOverride = + languageId == null ? undefined : reference.languageOverrides?.[languageId]; + const delimiters = + languageOverride?.matchingDelimiters ?? reference.matchingDelimiters; - ruby: { - doubleQuotes: ['"', '"', { isSingleLine: false }], - tripleDoubleQuotes: ["%Q(", ")"], - }, + if (delimiters == null) { + throw new Error(`No matching delimiters defined for '${name}'`); + } - clojure: { - doubleQuotes: ['"', '"', { isSingleLine: false }], - }, + const isSingleLine = languageOverride?.isSingleLine ?? reference.isSingleLine; - csharp: { - doubleQuotes: [ - ['@"', '"'], - ['"', '"'], - ], - }, -}; + return isSingleLine + ? [delimiters[0], delimiters[1], { isSingleLine: true }] + : [delimiters[0], delimiters[1]]; +} export const leftToRightMap: Record = Object.fromEntries( - Object.values(delimiterToText), + Object.values(matchingDelimiterMap), ); /** @@ -99,7 +76,7 @@ export const complexDelimiterMap: Record< ComplexSurroundingPairName, SimpleSurroundingPairName[] > = { - any: unsafeKeys(delimiterToText), + any: unsafeKeys(matchingDelimiterMap), string: [ "tripleDoubleQuotes", "tripleSingleQuotes", @@ -139,12 +116,16 @@ export function getSimpleDelimiterMap( | [IndividualDelimiterText, IndividualDelimiterText] | [IndividualDelimiterText, IndividualDelimiterText, Options] > { - if (languageId != null && languageId in delimiterToTextOverrides) { - return { - ...delimiterToText, - ...delimiterToTextOverrides[languageId], - }; + if (languageId == null) { + return matchingDelimiterMap; + } + + let result = matchingDelimiterMapCache.get(languageId); + + if (result == null) { + result = getMatchingDelimiterMap(languageId); + matchingDelimiterMapCache.set(languageId, result); } - return delimiterToText; + return result; } diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getIndividualDelimiters.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getIndividualDelimiters.ts index 071ef4d5dba..66d8372d157 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getIndividualDelimiters.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getIndividualDelimiters.ts @@ -33,10 +33,10 @@ function getSimpleIndividualDelimiters( languageId: string | undefined, delimiters: SimpleSurroundingPairName[], ): IndividualDelimiter[] { - const delimiterToText = getSimpleDelimiterMap(languageId); + const matchingDelimiterMap = getSimpleDelimiterMap(languageId); return delimiters.flatMap((delimiterName) => { const [leftDelimiter, rightDelimiter, options] = - delimiterToText[delimiterName]; + matchingDelimiterMap[delimiterName]; const { isSingleLine = false } = options ?? {}; // Allow for the fact that a delimiter might have multiple ways to indicate diff --git a/packages/lib-engine/src/processTargets/targets/ScopeTypeTarget.ts b/packages/lib-engine/src/processTargets/targets/ScopeTypeTarget.ts index d022956d738..4b0e323a812 100644 --- a/packages/lib-engine/src/processTargets/targets/ScopeTypeTarget.ts +++ b/packages/lib-engine/src/processTargets/targets/ScopeTypeTarget.ts @@ -3,6 +3,7 @@ import type { Range, SimpleScopeTypeType, } from "@cursorless/lib-common"; +import { getDefaultInsertionDelimiter } from "@cursorless/lib-common"; import type { Target } from "../../typings/target.types"; import { toGeneralizedRange } from "../../util/targetUtils"; import type { CommonTargetParameters } from "./BaseTarget"; @@ -43,7 +44,7 @@ export class ScopeTypeTarget extends BaseTarget { this.prefixRange = parameters.prefixRange; this.insertionDelimiter = parameters.insertionDelimiter ?? - getInsertionDelimiter(parameters.scopeTypeType); + getDefaultInsertionDelimiter(parameters.scopeTypeType); this.hasDelimiterRange_ = this.leadingDelimiterRange_ != null || this.trailingDelimiterRange_ != null; @@ -135,37 +136,3 @@ export class ScopeTypeTarget extends BaseTarget { }; } } - -function getInsertionDelimiter(scopeType: SimpleScopeTypeType): string { - switch (scopeType) { - case "class": - case "namedFunction": - case "section": - case "sectionLevelOne": - case "sectionLevelTwo": - case "sectionLevelThree": - case "sectionLevelFour": - case "sectionLevelFive": - case "sectionLevelSix": - case "part": - case "chapter": - case "subSection": - case "subSubSection": - case "namedParagraph": - case "subParagraph": - return "\n\n"; - - case "anonymousFunction": - case "statement": - case "ifStatement": - case "comment": - case "xmlElement": - case "collectionItem": - case "branch": - case "environment": - return "\n"; - - default: - return " "; - } -} diff --git a/packages/lib-engine/src/scopeProviders/scopeTypeToString.ts b/packages/lib-engine/src/scopeProviders/scopeTypeToString.ts index cdc3320c6cb..4c426696d9f 100644 --- a/packages/lib-engine/src/scopeProviders/scopeTypeToString.ts +++ b/packages/lib-engine/src/scopeProviders/scopeTypeToString.ts @@ -1,11 +1,7 @@ import type { ScopeType } from "@cursorless/lib-common"; -import { camelCaseToAllDown, isSimpleScopeType } from "@cursorless/lib-common"; +import { camelCaseToAllDown, scopeReferences } from "@cursorless/lib-common"; export function scopeTypeToString(scopeType: ScopeType): string { - if (isSimpleScopeType(scopeType)) { - return camelCaseToAllDown(scopeType.type).replace(".", " "); - } - if (scopeType.type === "surroundingPair") { return `Matching pair of ${camelCaseToAllDown(scopeType.delimiter)}`; } @@ -14,5 +10,5 @@ export function scopeTypeToString(scopeType: ScopeType): string { return `Regex \`${scopeType.regex}\``; } - return "Unknown scope type"; + return scopeReferences[scopeType.type].name; } diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts index b5132d92f70..98fbd34977d 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts @@ -57,7 +57,7 @@ function helloWorld() { function getExpectedScope(scopeSupport: ScopeSupport): ScopeSupportInfo { return { - humanReadableName: "named function", + humanReadableName: "Named function", isLanguageSpecific: true, iterationScopeSupport: scopeSupport, scopeType: { diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts index 77f8fc939eb..2d2eeb4f51a 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts @@ -127,7 +127,7 @@ const squareMissing: ScopeTypeInfo = { }; const namedFunctionStandard: ScopeTypeInfo = { - humanReadableName: "named function", + humanReadableName: "Named function", isLanguageSpecific: true, scopeType: { type: "namedFunction" }, spokenForm: { @@ -137,7 +137,7 @@ const namedFunctionStandard: ScopeTypeInfo = { }; const namedFunctionCustom: ScopeTypeInfo = { - humanReadableName: "named function", + humanReadableName: "Named function", isLanguageSpecific: true, scopeType: { type: "namedFunction" }, spokenForm: { @@ -147,7 +147,7 @@ const namedFunctionCustom: ScopeTypeInfo = { }; const lambdaStandard: ScopeTypeInfo = { - humanReadableName: "anonymous function", + humanReadableName: "Anonymous function", isLanguageSpecific: true, scopeType: { type: "anonymousFunction" }, spokenForm: { @@ -157,7 +157,7 @@ const lambdaStandard: ScopeTypeInfo = { }; const lambdaCustom: ScopeTypeInfo = { - humanReadableName: "anonymous function", + humanReadableName: "Anonymous function", isLanguageSpecific: true, scopeType: { type: "anonymousFunction" }, spokenForm: { @@ -169,7 +169,7 @@ const lambdaCustom: ScopeTypeInfo = { }; const statementStandard: ScopeTypeInfo = { - humanReadableName: "statement", + humanReadableName: "Statement", isLanguageSpecific: true, scopeType: { type: "statement" }, spokenForm: { @@ -179,7 +179,7 @@ const statementStandard: ScopeTypeInfo = { }; const statementMissing: ScopeTypeInfo = { - humanReadableName: "statement", + humanReadableName: "Statement", isLanguageSpecific: true, scopeType: { type: "statement" }, spokenForm: { diff --git a/packages/tool-meta-updater/src/updatePairedDelimitersMd.ts b/packages/tool-meta-updater/src/updatePairedDelimitersMd.ts index b1128b32f20..4242c093856 100644 --- a/packages/tool-meta-updater/src/updatePairedDelimitersMd.ts +++ b/packages/tool-meta-updater/src/updatePairedDelimitersMd.ts @@ -22,10 +22,10 @@ export function updatePairedDelimitersMd( const rows = Object.values(entries) .filter( - (entry): entry is PairedDelimiterReference & { referenceIndex: number } => - !entry.private && entry.referenceIndex != null, + (entry): entry is PairedDelimiterReference & { index: number } => + !entry.private && entry.index != null, ) - .toSorted((a, b) => a.referenceIndex - b.referenceIndex) + .toSorted((a, b) => a.index - b.index) .map((entry) => { const [before, after] = entry.delimiters ?? [null, null]; const spokenForm = `${code(`"${entry.defaultSpokenForm}"`)}${entry.disabledByDefault ? ` (${DISABLED_BY_DEFAULT})` : ""}`; @@ -36,7 +36,7 @@ export function updatePairedDelimitersMd( before == null ? "N/A" : code(formatDelimiter(before)), after == null ? "N/A" : code(formatDelimiter(after)), booleanIcon(entry.delimiters != null), - booleanIcon(entry.selectable), + booleanIcon(entry.matchingDelimiters != null), ]; });