diff --git a/README.md b/README.md index 42d0433..475f9f8 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ character. Most keybindings exposed by Dance are actually implemented by running several Dance commands in a row. For instance, `dance.modes.set.normal` is actually a -wrapper around `dance.modes.set` with the argument `{ input: "normal" }`. +wrapper around `dance.modes.set` with the argument `{ mode: "normal" }`. Commands that take an input, like `dance.modes.set`, will prompt a user for a value if no argument is given. diff --git a/src/commands/README.build.ts b/src/commands/README.build.ts index f993266..b487213 100644 --- a/src/commands/README.build.ts +++ b/src/commands/README.build.ts @@ -100,12 +100,10 @@ function determineSupportedInputs(f: Builder.ParsedFunction) { supported.push("may be repeated with a given number of repetitions"); } else if (match = /^RegisterOr<"(\w+)"(?:, .+)?>$/.exec(type)) { supported.push(`accepts a register (by default, it uses \`${match[1]}\`)`); - } else if (match = /^InputOr<(\w+)>$/.exec(type)) { - supported.push(`takes an input of type \`${match[1]}\``); } else if (match = /^Argument<(.+)>( \| undefined)$/.exec(type)) { supported.push(`takes an argument \`${name}\` of type \`${match[1]}\``); - } else if (name === "input") { - supported.push(`takes an input of type \`${type}\``); + } else if (match = /^InputOr<"(\w+?)", (.+)>/.exec(type)) { + supported.push(`takes an input \`${match[1]}\` of type \`${match[2]}\``); } else if (name === "argument") { supported.push(`accepts an argument of type \`${type}\``); } else if (/^(Context|vscode.Text(Editor|Document))$/.test(type) || name === "selections") { diff --git a/src/commands/README.md b/src/commands/README.md index 7d145bf..feb9a9d 100644 --- a/src/commands/README.md +++ b/src/commands/README.md @@ -173,19 +173,19 @@ selections.selectSelect within selectionsS (editorTextFocus && dance.mode == 'normal') selections.clear.mainClear main selectionsAlt+Space (editorTextFocus && dance.mode == 'normal') selections.clear.secondaryClear secondary selectionsSpace (editorTextFocus && dance.mode == 'normal') - selections.copy.aboveCopy selections aboveShift+Alt+C (editorTextFocus && dance.mode == 'normal') - selections.faceBackwardBackward selections - selections.faceForwardForward selectionsShift+Alt+; (editorTextFocus && dance.mode == 'normal') + selections.copy.aboveCopy selections aboveShift+Alt+C (editorTextFocus && dance.mode == 'normal') + selections.faceBackwardBackward selections + selections.faceForwardForward selectionsShift+Alt+; (editorTextFocus && dance.mode == 'normal') selections.filter.regexpKeep matching selectionsAlt+K (editorTextFocus && dance.mode == 'normal') selections.filter.regexp.inverseClear matching selectionsShift+Alt+K (editorTextFocus && dance.mode == 'normal') - selections.hideIndicesHide selection indices - selections.orderAscendingOrder selections ascending - selections.orderDescendingOrder selections descending + selections.hideIndicesHide selection indices + selections.orderAscendingOrder selections ascending + selections.orderDescendingOrder selections descending selections.pipe.appendPipe and appendShift+1 (editorTextFocus && dance.mode == 'normal') selections.pipe.prependPipe and prependShift+Alt+1 (editorTextFocus && dance.mode == 'normal') selections.pipe.replacePipe and replaceShift+\ (editorTextFocus && dance.mode == 'normal') - selections.reduce.edgesReduce selections to their endsShift+Alt+S (editorTextFocus && dance.mode == 'normal') - selections.showIndicesShow selection indices + selections.reduce.edgesReduce selections to their endsShift+Alt+S (editorTextFocus && dance.mode == 'normal') + selections.showIndicesShow selection indices selections.sortSort selections selections.splitSplit selectionsShift+S (editorTextFocus && dance.mode == 'normal') selections.splitLinesSplit selections at line boundariesAlt+S (editorTextFocus && dance.mode == 'normal') @@ -388,6 +388,7 @@ Replace characters. This command: - may be repeated with a given number of repetitions. +- takes an input `input` of type `string`. Default keybinding: `r` (normal) @@ -641,8 +642,8 @@ This command: Run code. There are two ways to invoke this command. The first one is to provide an -`input` string argument. This input must be a valid JavaScript string, and -will be executed with full access to the [Dance API](../api/README.md). For +`code` string argument. This code must be a valid JavaScript string, and will +be executed with full access to the [Dance API](../api/README.md). For instance, ```json @@ -738,14 +739,15 @@ code execution is enabled, or `commands` otherwise. This command: - accepts a register (by default, it uses `null`). -- accepts an argument of type `Record<"code" | "input", string | readonly string[]>`. +- accepts an argument of type `{ code?: string | readonly string[] }`. - may be repeated with a given number of repetitions. - may be repeated with a given number of repetitions. - takes an argument `commands` of type `command.Any[]`. +- takes an input `code` of type `string | readonly string[]`. -### [`selectRegister`](./misc.ts#L186-L200) +### [`selectRegister`](./misc.ts#L184-L198) Select register for next command. @@ -755,22 +757,25 @@ press is awaited again and the returned register will be specific to the current document. +This command: +- takes an input `register` of type `string | Register`. Default keybinding: `"` (normal) -### [`updateRegister`](./misc.ts#L216-L227) +### [`updateRegister`](./misc.ts#L214-L225) Update the contents of a register. This command: - accepts a register (by default, it uses `dquote`). +- takes an input `input` of type `string`. -### [`updateCount`](./misc.ts#L253-L282) +### [`updateCount`](./misc.ts#L251-L280) Update Dance count. @@ -795,14 +800,15 @@ Update the current counter used to repeat the next command. This command: - may be repeated with a given number of repetitions. - takes an argument `addDigits` of type `number`. +- takes an input `count` of type `number`. -### [`openMenu`](./misc.ts#L310-L332) +### [`openMenu`](./misc.ts#L308-L330) Open menu. -If no input is specified, a prompt will ask for the name of the menu to open. +If no menu is specified, a prompt will ask for the name of the menu to open. Alternatively, a `menu` can be inlined in the arguments. @@ -818,10 +824,11 @@ This command: - takes an argument `pass` of type `any[]`. - takes an argument `prefix` of type `string`. - takes an argument `title` of type `string`. +- takes an input `menu` of type `string | Menu`. -### [`changeInput`](./misc.ts#L373-L387) +### [`changeInput`](./misc.ts#L371-L385) Change current input. @@ -862,6 +869,10 @@ Other variants are provided to switch to insert mode: | Insert at line start | `insert.lineStart` | `s-i` (normal) | `[".select.lineStart", { shift: "jump", skipBlank: true }], [".modes.set", { mode: "insert", +mode }], [".selections.reduce", { where: "start", record: false, empty: true, ... }]` | | Insert at line end | `insert.lineEnd` | `s-a` (normal) | `[".select.lineEnd" , { shift: "jump" }], [".modes.set", { mode: "insert", +mode }], [".selections.reduce", { where: "end" , record: false, empty: true, ... }]` | + +This command: +- takes an input `mode` of type `string`. + ### [`modes.set.temporarily`](./modes.ts#L34-L46) @@ -878,6 +889,7 @@ Set Dance mode temporarily. This command: - may be repeated with a given number of repetitions. +- takes an input `mode` of type `string`. ## [`search`](./search.ts) @@ -898,7 +910,7 @@ Search. This command: - accepts a register (by default, it uses `slash`). -- accepts an argument of type `{ input?: string | RegExp }`. +- accepts an argument of type `{ re?: string | RegExp }`. - may be repeated with a given number of repetitions. - takes an argument `add` of type `boolean`. - takes an argument `interactive` of type `boolean`. @@ -968,6 +980,7 @@ Select to character (excluded). This command: - may be repeated with a given number of repetitions. - takes an argument `include` of type `boolean`. +- takes an input `input` of type `string`. Default keybinding: `t` (normal) @@ -1057,6 +1070,7 @@ Select object. This command: - takes an argument `inner` of type `boolean`. - takes an argument `where` of type `"start" | "end"`. +- takes an input `input` of type `string`. ## [`select`](./select.ts) @@ -1361,14 +1375,15 @@ See https://github.com/mawww/kakoune/blob/master/doc/pages/keys.asciidoc#changes #### Additional commands -| Title | Identifier | Keybinding | Commands | -| ------------------- | -------------- | -------------- | ----------------------------------------------------------------------------------------------------- | -| Pipe and replace | `pipe.replace` | `\|` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "\|" , ... }]` | -| Pipe and append | `pipe.append` | `!` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "\|", where: "end" , ... }]` | -| Pipe and prepend | `pipe.prepend` | `a-!` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "\|", where: "start", ... }]` | +| Title | Identifier | Keybinding | Commands | +| ------------------- | -------------- | -------------- | ---------------------------------------------------------------------------------------------------------- | +| Pipe and replace | `pipe.replace` | `\|` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "\|" , ... }]` | +| Pipe and append | `pipe.append` | `!` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "\|", where: "end" , ... }]` | +| Pipe and prepend | `pipe.prepend` | `a-!` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "\|", where: "start", ... }]` | This command: - accepts a register (by default, it uses `pipe`). +- takes an input `expression` of type `string`. Default keybinding: `a-|` (normal) @@ -1381,17 +1396,17 @@ Filter selections. #### Variants -| Title | Identifier | Keybinding | Commands | -| -------------------------- | ----------------------- | ------------------ | ------------------------------------------------------------------- | -| Keep matching selections | `filter.regexp` | `a-k` (normal) | `[".selections.filter", { defaultInput: "/" , ... }]` | -| Clear matching selections | `filter.regexp.inverse` | `s-a-k` (normal) | `[".selections.filter", { defaultInput: "/", inverse: true, ... }]` | -| Clear secondary selections | `clear.secondary` | `space` (normal) | `[".selections.filter", { input: "i === count" , ... }]` | -| Clear main selections | `clear.main` | `a-space` (normal) | `[".selections.filter", { input: "i !== count" , ... }]` | +| Title | Identifier | Keybinding | Commands | +| -------------------------- | ----------------------- | ------------------ | ------------------------------------------------------------------------ | +| Keep matching selections | `filter.regexp` | `a-k` (normal) | `[".selections.filter", { defaultExpression: "/" , ... }]` | +| Clear matching selections | `filter.regexp.inverse` | `s-a-k` (normal) | `[".selections.filter", { defaultExpression: "/", inverse: true, ... }]` | +| Clear secondary selections | `clear.secondary` | `space` (normal) | `[".selections.filter", { expression: "i === count" , ... }]` | +| Clear main selections | `clear.main` | `a-space` (normal) | `[".selections.filter", { expression: "i !== count" , ... }]` | This command: -- accepts an argument of type `{ input?: string }`. +- accepts an argument of type `{ expression?: string }`. - may be repeated with a given number of repetitions. -- takes an argument `defaultInput` of type `string`. +- takes an argument `defaultExpression` of type `string`. - takes an argument `interactive` of type `boolean`. - takes an argument `inverse` of type `boolean`. @@ -1399,26 +1414,26 @@ Default keybinding: `$` (normal) -### [`selections.select`](./selections.ts#L340-L350) +### [`selections.select`](./selections.ts#L342-L352) Select within selections. This command: -- accepts an argument of type `{ input?: string | RegExp }`. +- accepts an argument of type `{ re?: string | RegExp }`. - takes an argument `interactive` of type `boolean`. Default keybinding: `s` (normal) -### [`selections.split`](./selections.ts#L369-L380) +### [`selections.split`](./selections.ts#L371-L382) Split selections. This command: -- accepts an argument of type `{ input?: string | RegExp }`. +- accepts an argument of type `{ re?: string | RegExp }`. - takes an argument `excludeEmpty` of type `boolean`. - takes an argument `interactive` of type `boolean`. @@ -1426,7 +1441,7 @@ Default keybinding: `s-s` (normal) -### [`selections.splitLines`](./selections.ts#L405-L416) +### [`selections.splitLines`](./selections.ts#L407-L418) Split selections at line boundaries. @@ -1439,7 +1454,7 @@ Default keybinding: `a-s` (normal) -### [`selections.expandToLines`](./selections.ts#L459-L466) +### [`selections.expandToLines`](./selections.ts#L461-L468) Expand to lines. @@ -1451,7 +1466,7 @@ Default keybinding: `a-x` (normal) -### [`selections.trimLines`](./selections.ts#L493-L500) +### [`selections.trimLines`](./selections.ts#L495-L502) Trim lines. @@ -1463,7 +1478,7 @@ Default keybinding: `s-a-x` (normal) -### [`selections.trimWhitespace`](./selections.ts#L525-L532) +### [`selections.trimWhitespace`](./selections.ts#L527-L534) Trim whitespace. @@ -1475,7 +1490,7 @@ Default keybinding: `_` (normal) -### [`selections.reduce`](./selections.ts#L551-L570) +### [`selections.reduce`](./selections.ts#L553-L572) Reduce selections to their cursor. @@ -1495,7 +1510,7 @@ Default keybinding: `;` (normal) -### [`selections.changeDirection`](./selections.ts#L632-L647) +### [`selections.changeDirection`](./selections.ts#L634-L649) Change direction of selections. @@ -1513,7 +1528,7 @@ Default keybinding: `a-;` (normal) -### [`selections.changeOrder`](./selections.ts#L672-L686) +### [`selections.changeOrder`](./selections.ts#L674-L688) Reverse selections. @@ -1527,13 +1542,18 @@ Reverse selections. -### [`selections.sort`](./selections.ts#L699-L711) +### [`selections.sort`](./selections.ts#L701-L713) Sort selections. + + +This command: +- takes an input `expression` of type `string`. + -### [`selections.copy`](./selections.ts#L784-L802) +### [`selections.copy`](./selections.ts#L786-L804) Copy selections below. @@ -1551,7 +1571,7 @@ Default keybinding: `s-c` (normal) -### [`selections.merge`](./selections.ts#L836-L841) +### [`selections.merge`](./selections.ts#L838-L843) Merge contiguous selections. @@ -1561,13 +1581,13 @@ Default keybinding: `a-_` (normal) -### [`selections.open`](./selections.ts#L845-L848) +### [`selections.open`](./selections.ts#L847-L850) Open selected file. -### [`selections.toggleIndices`](./selections.ts#L862-L879) +### [`selections.toggleIndices`](./selections.ts#L864-L881) Toggle selection indices. diff --git a/src/commands/load-all.ts b/src/commands/load-all.ts index 412c92c..f1768d0 100644 --- a/src/commands/load-all.ts +++ b/src/commands/load-all.ts @@ -575,7 +575,7 @@ export const commands: Commands = function () { ), "dance.selections.filter": new CommandDescriptor( "dance.selections.filter", - (_, argument) => _.runAsync((_) => selections_filter(_, argument, argument["defaultInput"], argument["inverse"], argument["interactive"], getCount(_, argument))), + (_, argument) => _.runAsync((_) => selections_filter(_, argument, argument["defaultExpression"], argument["inverse"], argument["interactive"], getCount(_, argument))), CommandDescriptor.Flags.RequiresActiveEditor, ), "dance.selections.merge": new CommandDescriptor( @@ -590,7 +590,7 @@ export const commands: Commands = function () { ), "dance.selections.pipe": new CommandDescriptor( "dance.selections.pipe", - (_, argument) => _.runAsync((_) => selections_pipe(_, getRegister(_, argument, "pipe", Register.Flags.CanWrite), getInputOr("input", argument))), + (_, argument) => _.runAsync((_) => selections_pipe(_, getRegister(_, argument, "pipe", Register.Flags.CanWrite), getInputOr("expression", argument))), CommandDescriptor.Flags.RequiresActiveEditor, ), "dance.selections.reduce": new CommandDescriptor( @@ -1188,43 +1188,43 @@ export const commands: Commands = function () { commands, "dance.selections.pipe.replace", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.pipe", { $include: ["input","register"] }], [".edit.insert", { register: "|" , $exclude: ["input","register"] }]], + [[".selections.pipe", { $include: ["expression","register"] }], [".edit.insert", { register: "|" , $exclude: ["expression","register"] }]], ); describeAdditionalCommand( commands, "dance.selections.pipe.append", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.pipe", { $include: ["input","register"] }], [".edit.insert", { register: "|", where: "end" , $exclude: ["input","register"] }]], + [[".selections.pipe", { $include: ["expression","register"] }], [".edit.insert", { register: "|", where: "end" , $exclude: ["expression","register"] }]], ); describeAdditionalCommand( commands, "dance.selections.pipe.prepend", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.pipe", { $include: ["input","register"] }], [".edit.insert", { register: "|", where: "start", $exclude: ["input","register"] }]], + [[".selections.pipe", { $include: ["expression","register"] }], [".edit.insert", { register: "|", where: "start", $exclude: ["expression","register"] }]], ); describeAdditionalCommand( commands, "dance.selections.filter.regexp", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.filter", { defaultInput: "/" , $exclude: [] }]], + [[".selections.filter", { defaultExpression: "/" , $exclude: [] }]], ); describeAdditionalCommand( commands, "dance.selections.filter.regexp.inverse", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.filter", { defaultInput: "/", inverse: true, $exclude: [] }]], + [[".selections.filter", { defaultExpression: "/", inverse: true, $exclude: [] }]], ); describeAdditionalCommand( commands, "dance.selections.clear.secondary", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.filter", { input: "i === count" , $exclude: [] }]], + [[".selections.filter", { expression: "i === count" , $exclude: [] }]], ); describeAdditionalCommand( commands, "dance.selections.clear.main", CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay, - [[".selections.filter", { input: "i !== count" , $exclude: [] }]], + [[".selections.filter", { expression: "i !== count" , $exclude: [] }]], ); describeAdditionalCommand( commands, diff --git a/src/commands/misc.ts b/src/commands/misc.ts index ff7f123..1fed0ce 100644 --- a/src/commands/misc.ts +++ b/src/commands/misc.ts @@ -40,8 +40,8 @@ const runHistory: string[] = []; * Run code. * * There are two ways to invoke this command. The first one is to provide an - * `input` string argument. This input must be a valid JavaScript string, and - * will be executed with full access to the [Dance API](../api/README.md). For + * `code` string argument. This code must be a valid JavaScript string, and will + * be executed with full access to the [Dance API](../api/README.md). For * instance, * * ```json @@ -137,7 +137,7 @@ const runHistory: string[] = []; */ export async function run( _: Context, - argument: Record<"code" | "input", string | readonly string[]>, + argument: { code?: string | readonly string[] }, codeOr: InputOr<"code", string | readonly string[]>, count: number, @@ -146,11 +146,9 @@ export async function run( commands?: Argument, ) { - argument["code"] ??= argument["input"]; - if (Array.isArray(commands)) { if (typeof argument["code"] === "string" && runIsEnabled()) { - // Prefer "input" to the "commands" array. + // Prefer "code" to the "commands" array. } else { return apiCommands(...commands); } @@ -198,16 +196,16 @@ export async function selectRegister( _: Context, registerOr: InputOr<"register", string | Register>, ) { - const input = await registerOr(() => keypressForRegister(_)); + const register = await registerOr(() => keypressForRegister(_)); - if (typeof input === "string") { - if (input.length === 0) { + if (typeof register === "string") { + if (register.length === 0) { return; } - _.extension.currentRegister = _.extension.registers.getPossiblyScoped(input, _.document); + _.extension.currentRegister = _.extension.registers.getPossiblyScoped(register, _.document); } else { - _.extension.currentRegister = input; + _.extension.currentRegister = register; } } @@ -310,7 +308,7 @@ const menuHistory: string[] = []; /** * Open menu. * - * If no input is specified, a prompt will ask for the name of the menu to open. + * If no menu is specified, a prompt will ask for the name of the menu to open. * * Alternatively, a `menu` can be inlined in the arguments. * diff --git a/src/commands/search.ts b/src/commands/search.ts index a41c6a8..1bfdd7c 100644 --- a/src/commands/search.ts +++ b/src/commands/search.ts @@ -32,17 +32,17 @@ export async function search( interactive: Argument = true, shift: Shift = Shift.Jump, - argument: { input?: string | RegExp }, + argument: { re?: string | RegExp }, ) { - return manipulateSelectionsInteractively(_, "input", argument, interactive, { + return manipulateSelectionsInteractively(_, "re", argument, interactive, { ...promptRegexpOpts("mu"), value: (await register.get())?.[0], - }, (input, selections) => { - if (typeof input === "string") { - input = new RegExp(input, "mu"); + }, (re, selections) => { + if (typeof re === "string") { + re = new RegExp(re, "mu"); } - register.set([input.source]); + register.set([re.source]); const newSelections = add ? selections.slice() : [], regexpMatches = [] as RegExpMatchArray[]; @@ -52,7 +52,7 @@ export async function search( for (let j = 0; j < repetitions; j++) { const searchResult = nextImpl( - input as RegExp, direction, newSelection, undefined, undefined, document, + re as RegExp, direction, newSelection, undefined, undefined, document, /* allowWrapping= */ shift !== Shift.Extend, regexpMatches, regexpMatches.length); if (searchResult === undefined) { @@ -74,7 +74,7 @@ export async function search( Selections.set(newSelections); _.extension.registers.updateRegExpMatches(regexpMatches); - return register.set([input.source]).then(() => input as RegExp); + return register.set([re.source]).then(() => re as RegExp); }); } diff --git a/src/commands/selections.ts b/src/commands/selections.ts index 809e81d..4e32bfe 100644 --- a/src/commands/selections.ts +++ b/src/commands/selections.ts @@ -248,18 +248,18 @@ const pipeHistory: string[] = []; * * #### Additional commands * - * | Title | Identifier | Keybinding | Commands | - * | ------------------- | -------------- | -------------- | ----------------------------------------------------------------------------------------------------- | - * | Pipe and replace | `pipe.replace` | `|` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "|" , ... }]` | - * | Pipe and append | `pipe.append` | `!` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "|", where: "end" , ... }]` | - * | Pipe and prepend | `pipe.prepend` | `a-!` (normal) | `[".selections.pipe", { +input,register }], [".edit.insert", { register: "|", where: "start", ... }]` | + * | Title | Identifier | Keybinding | Commands | + * | ------------------- | -------------- | -------------- | ---------------------------------------------------------------------------------------------------------- | + * | Pipe and replace | `pipe.replace` | `|` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "|" , ... }]` | + * | Pipe and append | `pipe.append` | `!` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "|", where: "end" , ... }]` | + * | Pipe and prepend | `pipe.prepend` | `a-!` (normal) | `[".selections.pipe", { +expression,register }], [".edit.insert", { register: "|", where: "start", ... }]` | */ export async function pipe( _: Context, register: RegisterOr<"pipe", Register.Flags.CanWrite>, - inputOr: InputOr<"input", string>, + expressionOr: InputOr<"expression", string>, ) { - const input = await inputOr(() => prompt({ + const expression = await expressionOr(() => prompt({ prompt: "Expression", validateInput(value) { try { @@ -276,7 +276,7 @@ export async function pipe( selectionsStrings = selections.map((selection) => document.getText(selection)); const results = await Promise.all(_.run((_) => selectionsStrings.map((string, i, strings) => - switchRun(input!, { $: string, $$: strings, i, n: strings.length }), + switchRun(expression!, { $: string, $$: strings, i, n: strings.length }), ))); const strings = results.map(resultToString); @@ -293,18 +293,18 @@ const filterHistory: string[] = []; * * #### Variants * - * | Title | Identifier | Keybinding | Commands | - * | -------------------------- | ----------------------- | ------------------ | ------------------------------------------------------------------- | - * | Keep matching selections | `filter.regexp` | `a-k` (normal) | `[".selections.filter", { defaultInput: "/" , ... }]` | - * | Clear matching selections | `filter.regexp.inverse` | `s-a-k` (normal) | `[".selections.filter", { defaultInput: "/", inverse: true, ... }]` | - * | Clear secondary selections | `clear.secondary` | `space` (normal) | `[".selections.filter", { input: "i === count" , ... }]` | - * | Clear main selections | `clear.main` | `a-space` (normal) | `[".selections.filter", { input: "i !== count" , ... }]` | + * | Title | Identifier | Keybinding | Commands | + * | -------------------------- | ----------------------- | ------------------ | ------------------------------------------------------------------------ | + * | Keep matching selections | `filter.regexp` | `a-k` (normal) | `[".selections.filter", { defaultExpression: "/" , ... }]` | + * | Clear matching selections | `filter.regexp.inverse` | `s-a-k` (normal) | `[".selections.filter", { defaultExpression: "/", inverse: true, ... }]` | + * | Clear secondary selections | `clear.secondary` | `space` (normal) | `[".selections.filter", { expression: "i === count" , ... }]` | + * | Clear main selections | `clear.main` | `a-space` (normal) | `[".selections.filter", { expression: "i !== count" , ... }]` | */ export function filter( _: Context, - argument: { input?: string }, - defaultInput?: Argument, + argument: { expression?: string }, + defaultExpression?: Argument, inverse: Argument = false, interactive: Argument = true, count: number = 0, @@ -312,7 +312,7 @@ export function filter( const document = _.document, strings = _.selections.map((selection) => document.getText(selection)); - return manipulateSelectionsInteractively(_, "input", argument, interactive, { + return manipulateSelectionsInteractively(_, "expression", argument, interactive, { prompt: "Expression", validateInput(value) { try { @@ -321,19 +321,21 @@ export function filter( return (e as Error)?.message ?? `${e}`; } }, - value: defaultInput, - valueSelection: defaultInput ? [defaultInput.length, defaultInput.length] : undefined, + value: defaultExpression, + valueSelection: defaultExpression + ? [defaultExpression.length, defaultExpression.length] + : undefined, history: filterHistory, - }, (input, selections) => { + }, (expression, selections) => { return Selections.filterByIndex(async (i) => { const context = { $: strings[i], $$: strings, i, n: strings.length, count }; try { - return !!(await switchRun(input, context)) !== inverse; + return !!(await switchRun(expression, context)) !== inverse; } catch { return inverse; } - }, selections).then(Selections.set).then(() => input); + }, selections).then(Selections.set).then(() => expression); }); } @@ -346,22 +348,22 @@ export function select( _: Context, interactive: Argument = true, - argument: { input?: string | RegExp }, + argument: { re?: string | RegExp }, ) { return manipulateSelectionsInteractively( _, - "input", + "re", argument, interactive, promptRegexpOpts("mu"), - (input, selections) => { - if (typeof input === "string") { - input = new RegExp(input, "mu"); + (re, selections) => { + if (typeof re === "string") { + re = new RegExp(re, "mu"); } - Selections.set(Selections.bottomToTop(Selections.selectWithin(input, selections))); + Selections.set(Selections.bottomToTop(Selections.selectWithin(re, selections))); - return Promise.resolve(input); + return Promise.resolve(re); }, ); } @@ -376,20 +378,20 @@ export function split( excludeEmpty: Argument = false, interactive: Argument = true, - argument: { input?: string | RegExp }, + argument: { re?: string | RegExp }, ) { return manipulateSelectionsInteractively( _, - "input", + "re", argument, interactive, promptRegexpOpts("mu"), - (input, selections) => { - if (typeof input === "string") { - input = new RegExp(input, "mu"); + (re, selections) => { + if (typeof re === "string") { + re = new RegExp(re, "mu"); } - let split = Selections.split(input, selections); + let split = Selections.split(re, selections); if (excludeEmpty) { split = split.filter((s) => !s.isEmpty); @@ -397,7 +399,7 @@ export function split( Selections.set(Selections.bottomToTop(split)); - return Promise.resolve(input); + return Promise.resolve(re); }, ); } diff --git a/src/state/status-bar.ts b/src/state/status-bar.ts index a3d6301..2ddb542 100644 --- a/src/state/status-bar.ts +++ b/src/state/status-bar.ts @@ -62,12 +62,12 @@ export class StatusBar implements vscode.Disposable { this.countSegment = this.addSegment( "Dance - Reset count", "symbol-number", - { command: "dance.updateCount", arguments: [{ input: "0" }], title: "" }, + { command: "dance.updateCount", arguments: [{ count: "0" }], title: "" }, ); this.registerSegment = this.addSegment( "Dance - Unset register", "clone", - { command: "dance.selectRegister", arguments: [{ input: "" }], title: "" }, + { command: "dance.selectRegister", arguments: [{ register: "" }], title: "" }, ); this.errorSegment = this.addSegment( "Dance - Copy and dismiss error", diff --git a/test/README.md b/test/README.md index dce1576..d8d2900 100644 --- a/test/README.md +++ b/test/README.md @@ -120,7 +120,7 @@ foo bar ## 1 search-b [up](#1) -- .search { input: "b" } +- .search { re: "b" } ``` foo bar diff --git a/test/suite/commands/pipe.md b/test/suite/commands/pipe.md index 6caafa8..c23b148 100644 --- a/test/suite/commands/pipe.md +++ b/test/suite/commands/pipe.md @@ -8,7 +8,7 @@ a b c d ## 1 pipe-replace-with-regexp [up](#1) -- .selections.pipe.replace { input: String.raw`/\s/-/g` } +- .selections.pipe.replace { expression: String.raw`/\s/-/g` } ``` a-b-c d @@ -18,7 +18,7 @@ a-b-c d ## 1 pipe-replace-with-regexp-newline [up](#1) -- .selections.pipe.replace { input: String.raw`/\s/\n/g` } +- .selections.pipe.replace { expression: String.raw`/\s/\n/g` } ``` a @@ -32,7 +32,7 @@ c d ## 1 pipe-replace-with-regexp-backslash-n [up](#1) -- .selections.pipe.replace { input: String.raw`/\s/\\n/g` } +- .selections.pipe.replace { expression: String.raw`/\s/\\n/g` } ``` a\nb\nc d @@ -42,7 +42,7 @@ a\nb\nc d ## 1 pipe-replace-with-regexp-backslash-newline [up](#1) -- .selections.pipe.replace { input: String.raw`/\s/\\\n/g` } +- .selections.pipe.replace { expression: String.raw`/\s/\\\n/g` } ``` a\ @@ -56,7 +56,7 @@ c d ## 1 pipe-replace-with-js [up](#1) -- .selections.pipe.replace { input: String.raw`$.replace(/\s/g, "-")` } +- .selections.pipe.replace { expression: String.raw`$.replace(/\s/g, "-")` } ``` a-b-c d @@ -66,7 +66,7 @@ a-b-c d ## 1 pipe-replace-with-js-newline [up](#1) -- .selections.pipe.replace { input: String.raw`$.replace(/\s/g, "\n")` } +- .selections.pipe.replace { expression: String.raw`$.replace(/\s/g, "\n")` } ``` a diff --git a/test/suite/commands/pipe.test.ts b/test/suite/commands/pipe.test.ts index 1997a8d..2614fd2 100644 --- a/test/suite/commands/pipe.test.ts +++ b/test/suite/commands/pipe.test.ts @@ -28,7 +28,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`/\s/-/g` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`/\s/-/g` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:8:1", 6, String.raw` @@ -45,7 +45,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`/\s/\n/g` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`/\s/\n/g` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:18:1", 6, String.raw` @@ -66,7 +66,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`/\s/\\n/g` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`/\s/\\n/g` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:32:1", 6, String.raw` @@ -83,7 +83,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`/\s/\\\n/g` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`/\s/\\\n/g` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:42:1", 6, String.raw` @@ -104,7 +104,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`$.replace(/\s/g, "-")` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`$.replace(/\s/g, "-")` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:56:1", 6, String.raw` @@ -121,7 +121,7 @@ suite("./test/suite/commands/pipe.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.pipe.replace", { input: String.raw`$.replace(/\s/g, "\n")` }); + await executeCommand("dance.selections.pipe.replace", { expression: String.raw`$.replace(/\s/g, "\n")` }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/pipe.md:66:1", 6, String.raw` diff --git a/test/suite/commands/search-next.md b/test/suite/commands/search-next.md index feb68e3..90786d9 100644 --- a/test/suite/commands/search-next.md +++ b/test/suite/commands/search-next.md @@ -10,7 +10,7 @@ kiwi orange kiwi ## 1 search-apple [up](#1) -- .search { input: "apple" } +- .search { re: "apple" } ``` apple pineapple pear diff --git a/test/suite/commands/search-next.test.ts b/test/suite/commands/search-next.test.ts index 834a24c..c19225d 100644 --- a/test/suite/commands/search-next.test.ts +++ b/test/suite/commands/search-next.test.ts @@ -30,7 +30,7 @@ suite("./test/suite/commands/search-next.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "apple" }); + await executeCommand("dance.search", { re: "apple" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search-next.md:10:1", 6, String.raw` diff --git a/test/suite/commands/search.md b/test/suite/commands/search.md index 2ac79f2..11bdf5d 100644 --- a/test/suite/commands/search.md +++ b/test/suite/commands/search.md @@ -8,7 +8,7 @@ foo bar ## easy search-b [up](#easy) -- .search { input: "b" } +- .search { re: "b" } ``` foo bar @@ -27,7 +27,7 @@ lazy dog quickly. ## 1 search [up](#1) -- .search { input: "brown" } +- .search { re: "brown" } ``` The quick brown fox @@ -39,7 +39,7 @@ lazy dog quickly. ## 1 search-repeat [up](#1) -- .search { input: "o", count: 2 } +- .search { re: "o", count: 2 } ``` The quick brown fox @@ -51,7 +51,7 @@ lazy dog quickly. ## 1 search-start [up](#1) -- .search { input: "quick" } +- .search { re: "quick" } Search starts **after** the selection so the first "quick" is not matched. @@ -65,7 +65,7 @@ lazy dog quickly. ## 1 search-start-wrap [up](#1) -- .search { input: "quick " } +- .search { re: "quick " } Search starts **after** the selection, but wraps over to find "quick ". @@ -79,7 +79,7 @@ lazy dog quickly. ## 1 search-wrap [up](#1) -- .search { input: "Th" } +- .search { re: "Th" } ``` The quick brown fox @@ -91,7 +91,7 @@ lazy dog quickly. ## 1 search-not-found [up](#1) -- .search { input: "pig", $expect: /^no selections remain$/ } +- .search { re: "pig", $expect: /^no selections remain$/ } No matches found. Selection is left untouched because otherwise there would be no selection left. @@ -106,7 +106,7 @@ lazy dog quickly. ## 1 search-backward [up](#1) -- .search { input: "Th", direction: -1 } +- .search { re: "Th", direction: -1 } Note: Selection always faces forward (except when extending). @@ -120,7 +120,7 @@ lazy dog quickly. ## 1 search-backward-wrap [up](#1) -- .search { input: "he", direction: -1 } +- .search { re: "he", direction: -1 } Search starts **before** the selection and wraps around to find the last "he". @@ -134,7 +134,7 @@ lazy dog quickly. ## 1 search-backward-wrap-other [up](#1) -- .search { input: "he q", direction: -1 } +- .search { re: "he q", direction: -1 } Search starts **before** the selection "q" but wraps around to find "he q". @@ -148,7 +148,7 @@ lazy dog quickly. ## 1 search-backward-not-found [up](#1) -- .search { input: "pig", direction: -1, $expect: /^no selections remain$/ } +- .search { re: "pig", direction: -1, $expect: /^no selections remain$/ } No matches found. Selection is left untouched because otherwise there would be no selection left. @@ -163,7 +163,7 @@ lazy dog quickly. ## 1 search-extend [up](#1) -- .search { input: "quick", shift: "extend" } +- .search { re: "quick", shift: "extend" } ``` The quick brown fox @@ -176,7 +176,7 @@ lazy dog quickly. ## 1 search-extend-wrap [up](#1) -- .search { input: "T", shift: "extend", $expect: /^no selections remain$/ } +- .search { re: "T", shift: "extend", $expect: /^no selections remain$/ } When extending, a selection is deleted if it would require wrapping to find the next match. In this case, the (only) main selection is left untouched because @@ -192,7 +192,7 @@ lazy dog quickly. ## 1 search-backward-extend [up](#1) -- .search { input: "T", direction: -1, shift: "extend" } +- .search { re: "T", direction: -1, shift: "extend" } When extending, the resulting selection may face backward. @@ -208,7 +208,7 @@ lazy dog quickly. > behavior <- character -- .search { input: "T", direction: -1, shift: "extend" } +- .search { re: "T", direction: -1, shift: "extend" } Note: "e" is included in character-selections because it is the anchor. @@ -222,7 +222,7 @@ lazy dog quickly. ## 1 search-backward-extend-other [up](#1) -- .search { input: "Th", direction: -1, shift: "extend" } +- .search { re: "Th", direction: -1, shift: "extend" } When extending, the resulting selection may face backward. @@ -238,7 +238,7 @@ lazy dog quickly. > behavior <- character -- .search { input: "Th", direction: -1, shift: "extend" } +- .search { re: "Th", direction: -1, shift: "extend" } Note: "e" is included in character-selections because it is the anchor. @@ -252,7 +252,7 @@ lazy dog quickly. ## 1 search-backward-extend-wrap [up](#1) -- .search { input: "lazy", direction: -1, shift: "extend", $expect: /^no selections remain$/ } +- .search { re: "lazy", direction: -1, shift: "extend", $expect: /^no selections remain$/ } When extending, a selection is deleted if it would require wrapping to find the next match. In this case, the (only) main selection is left untouched because @@ -281,7 +281,7 @@ lazy dog quickly. ## 2 search [up](#2) -- .search { input: "o" } +- .search { re: "o" } Forward search starts at "y" and finds "d**o**g" instead of "br**o**wn". @@ -295,7 +295,7 @@ lazy dog quickly. ## 2 search-extend [up](#2) -- .search { input: "o", shift: "extend" } +- .search { re: "o", shift: "extend" } Same, but extends instead of jumping. @@ -311,7 +311,7 @@ lazy dog quickly. > behavior <- character -- .search { input: "o", shift: "extend" } +- .search { re: "o", shift: "extend" } Same, but extends instead of jumping. @@ -325,7 +325,7 @@ lazy dog quickly. ## 2 search-wrap [up](#2) -- .search { input: "he" } +- .search { re: "he" } Forward search starts at "y" and wraps to "T**he**" instead of "t**he**". @@ -339,7 +339,7 @@ lazy dog quickly. ## 2 search-extend-wrap [up](#2) -- .search { input: "he", shift: "extend", $expect: /^no selections remain$/ } +- .search { re: "he", shift: "extend", $expect: /^no selections remain$/ } When extending, Dance should not wrap around document edges to find "T**he**". "t**he**" is not considered at all. No-op due to no selections remaining. @@ -355,7 +355,7 @@ lazy dog quickly. ## 2 search-backward [up](#2) -- .search { input: "u", direction: -1 } +- .search { re: "u", direction: -1 } Backward search starts at "b" and finds "q**u**ick" instead of "j**u**mps". @@ -369,7 +369,7 @@ lazy dog quickly. ## 2 search-backward-extend [up](#2) -- .search { input: "u", direction: -1, shift: "extend" } +- .search { re: "u", direction: -1, shift: "extend" } Same, but extends instead of jumping. @@ -384,7 +384,7 @@ lazy dog quickly. ## 2 search-backward-wrap [up](#2) -- .search { input: "o", direction: -1 } +- .search { re: "o", direction: -1 } Backward search starts at "b" and wraps to "d**o**g" instead of "br**o**wn". @@ -398,7 +398,7 @@ lazy dog quickly. ## 2 search-backward-extend-wrap [up](#2) -- .search { input: "o", direction: -1, shift: "extend", $expect: /^no selections remain$/ } +- .search { re: "o", direction: -1, shift: "extend", $expect: /^no selections remain$/ } When extending, Dance should not wrap around document edges to find "d**o**g". "br**o**wn" is not considered at all. No-op due to no selections remaining. diff --git a/test/suite/commands/search.test.ts b/test/suite/commands/search.test.ts index 14b1078..d8390d9 100644 --- a/test/suite/commands/search.test.ts +++ b/test/suite/commands/search.test.ts @@ -28,7 +28,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "b" }); + await executeCommand("dance.search", { re: "b" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:8:1", 6, String.raw` @@ -47,7 +47,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "brown" }); + await executeCommand("dance.search", { re: "brown" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:27:1", 6, String.raw` @@ -68,7 +68,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "o", count: 2 }); + await executeCommand("dance.search", { re: "o", count: 2 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:39:1", 6, String.raw` @@ -89,7 +89,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "quick" }); + await executeCommand("dance.search", { re: "quick" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:51:1", 6, String.raw` @@ -110,7 +110,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "quick " }); + await executeCommand("dance.search", { re: "quick " }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:65:1", 6, String.raw` @@ -131,7 +131,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "Th" }); + await executeCommand("dance.search", { re: "Th" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:79:1", 6, String.raw` @@ -152,7 +152,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "pig", $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "pig", $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:91:1", 6, String.raw` @@ -173,7 +173,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "Th", direction: -1 }); + await executeCommand("dance.search", { re: "Th", direction: -1 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:106:1", 6, String.raw` @@ -194,7 +194,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "he", direction: -1 }); + await executeCommand("dance.search", { re: "he", direction: -1 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:120:1", 6, String.raw` @@ -215,7 +215,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "he q", direction: -1 }); + await executeCommand("dance.search", { re: "he q", direction: -1 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:134:1", 6, String.raw` @@ -236,7 +236,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "pig", direction: -1, $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "pig", direction: -1, $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:148:1", 6, String.raw` @@ -257,7 +257,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "quick", shift: "extend" }); + await executeCommand("dance.search", { re: "quick", shift: "extend" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:163:1", 6, String.raw` @@ -279,7 +279,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "T", shift: "extend", $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "T", shift: "extend", $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:176:1", 6, String.raw` @@ -300,7 +300,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "T", direction: -1, shift: "extend" }); + await executeCommand("dance.search", { re: "T", direction: -1, shift: "extend" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:192:1", 6, String.raw` @@ -322,7 +322,7 @@ suite("./test/suite/commands/search.md", function () { // Perform all operations. await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "character" }); - await executeCommand("dance.search", { input: "T", direction: -1, shift: "extend" }); + await executeCommand("dance.search", { re: "T", direction: -1, shift: "extend" }); await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "caret" }); // Ensure document is as expected. @@ -344,7 +344,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "Th", direction: -1, shift: "extend" }); + await executeCommand("dance.search", { re: "Th", direction: -1, shift: "extend" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:222:1", 6, String.raw` @@ -366,7 +366,7 @@ suite("./test/suite/commands/search.md", function () { // Perform all operations. await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "character" }); - await executeCommand("dance.search", { input: "Th", direction: -1, shift: "extend" }); + await executeCommand("dance.search", { re: "Th", direction: -1, shift: "extend" }); await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "caret" }); // Ensure document is as expected. @@ -388,7 +388,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "lazy", direction: -1, shift: "extend", $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "lazy", direction: -1, shift: "extend", $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:252:1", 6, String.raw` @@ -410,7 +410,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "o" }); + await executeCommand("dance.search", { re: "o" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:281:1", 6, String.raw` @@ -432,7 +432,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "o", shift: "extend" }); + await executeCommand("dance.search", { re: "o", shift: "extend" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:295:1", 6, String.raw` @@ -455,7 +455,7 @@ suite("./test/suite/commands/search.md", function () { // Perform all operations. await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "character" }); - await executeCommand("dance.search", { input: "o", shift: "extend" }); + await executeCommand("dance.search", { re: "o", shift: "extend" }); await executeCommand("dance.dev.setSelectionBehavior", { mode: "normal", value: "caret" }); // Ensure document is as expected. @@ -478,7 +478,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "he" }); + await executeCommand("dance.search", { re: "he" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:325:1", 6, String.raw` @@ -500,7 +500,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "he", shift: "extend", $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "he", shift: "extend", $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:339:1", 6, String.raw` @@ -523,7 +523,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "u", direction: -1 }); + await executeCommand("dance.search", { re: "u", direction: -1 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:355:1", 6, String.raw` @@ -545,7 +545,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "u", direction: -1, shift: "extend" }); + await executeCommand("dance.search", { re: "u", direction: -1, shift: "extend" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:369:1", 6, String.raw` @@ -568,7 +568,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "o", direction: -1 }); + await executeCommand("dance.search", { re: "o", direction: -1 }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:384:1", 6, String.raw` @@ -590,7 +590,7 @@ suite("./test/suite/commands/search.md", function () { `); // Perform all operations. - await executeCommand("dance.search", { input: "o", direction: -1, shift: "extend", $expect: /^no selections remain$/ }); + await executeCommand("dance.search", { re: "o", direction: -1, shift: "extend", $expect: /^no selections remain$/ }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/search.md:398:1", 6, String.raw` diff --git a/test/suite/commands/selections-select.md b/test/suite/commands/selections-select.md index 7d3e3dc..46b5898 100644 --- a/test/suite/commands/selections-select.md +++ b/test/suite/commands/selections-select.md @@ -10,7 +10,7 @@ baz ## 1 select [up](#1) -- .selections.select { input: "b" } +- .selections.select { re: "b" } ``` foo bar diff --git a/test/suite/commands/selections-select.test.ts b/test/suite/commands/selections-select.test.ts index 764e369..5f2df81 100644 --- a/test/suite/commands/selections-select.test.ts +++ b/test/suite/commands/selections-select.test.ts @@ -30,7 +30,7 @@ suite("./test/suite/commands/selections-select.md", function () { `); // Perform all operations. - await executeCommand("dance.selections.select", { input: "b" }); + await executeCommand("dance.selections.select", { re: "b" }); // Ensure document is as expected. ExpectedDocument.assertEquals(editor, "./test/suite/commands/selections-select.md:10:1", 6, String.raw`