diff --git a/extension.ts b/extension.ts index c561e34b9..d08a254e6 100644 --- a/extension.ts +++ b/extension.ts @@ -54,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) { await vscode.window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path.`'); } }, - false + false, ); } diff --git a/extensionBase.ts b/extensionBase.ts index 0540f45b2..8a236fe50 100644 --- a/extensionBase.ts +++ b/extensionBase.ts @@ -27,7 +27,7 @@ interface ICodeKeybinding { } export async function getAndUpdateModeHandler( - forceSyncAndUpdate = false + forceSyncAndUpdate = false, ): Promise { const activeTextEditor = vscode.window.activeTextEditor; if (activeTextEditor === undefined || activeTextEditor.document.isClosed) { @@ -122,7 +122,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo Logger.info('Configuration changed'); await loadConfiguration(); }, - false + false, ); registerEventListener(context, vscode.workspace.onDidChangeTextDocument, async (event) => { @@ -136,7 +136,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo } Logger.debug( - `${event.contentChanges.length} change(s) to ${event.document.fileName} because ${event.reason}` + `${event.contentChanges.length} change(s) to ${event.document.fileName} because ${event.reason}`, ); for (const x of event.contentChanges) { Logger.trace(`\t-${x.rangeLength}, +'${x.text}'`); @@ -204,7 +204,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo } } }, - false + false, ); // window events @@ -250,12 +250,12 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo if (mh) { globalState.jumpTracker.handleFileJump( lastClosedModeHandler ? Jump.fromStateNow(lastClosedModeHandler.vimState) : null, - Jump.fromStateNow(mh.vimState) + Jump.fromStateNow(mh.vimState), ); } }, true, - true + true, ); registerEventListener( @@ -285,13 +285,13 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo (hash, s) => hash + `[${s.anchor.line}, ${s.anchor.character}; ${s.active.line}, ${s.active.character}]`, - '' + '', ); const idx = mh.selectionsChanged.ourSelections.indexOf(selectionsHash); if (idx > -1) { mh.selectionsChanged.ourSelections.splice(idx, 1); Logger.trace( - `Ignoring selection: ${selectionsHash}. ${mh.selectionsChanged.ourSelections.length} left` + `Ignoring selection: ${selectionsHash}. ${mh.selectionsChanged.ourSelections.length} left`, ); return; } else if (mh.selectionsChanged.ignoreIntermediateSelections) { @@ -325,7 +325,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo await mh.handleSelectionChange(e); }, true, - false + false, ); registerEventListener( @@ -344,7 +344,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo StatusBar.clear(mh.vimState, true); } } - } + }, ); const compositionState = new CompositionState(); @@ -372,7 +372,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo compositionState.composingText = compositionState.composingText.substr( 0, - compositionState.composingText.length - args.replaceCharCnt + compositionState.composingText.length - args.replaceCharCnt, ) + args.text; } if (compositionState.insertedText) { @@ -439,7 +439,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo if (!args) { throw new Error( - "'args' is undefined. For this remap to work it needs to have 'args' with an '\"after\": string[]' and/or a '\"commands\": { command: string; args: any[] }[]'" + "'args' is undefined. For this remap to work it needs to have 'args' with an '\"after\": string[]' and/or a '\"commands\": { command: string; args: any[] }[]'", ); } @@ -455,7 +455,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo if (command.command.startsWith(':')) { await new ExCommandLine( command.command.slice(1, command.command.length), - mh.vimState.currentMode + mh.vimState.currentMode, ).run(mh.vimState); mh.updateView(); } else { @@ -544,7 +544,7 @@ async function toggleExtension(isDisabled: boolean, compositionState: Compositio function overrideCommand( context: vscode.ExtensionContext, command: string, - callback: (...args: any[]) => any + callback: (...args: any[]) => any, ) { const disposable = vscode.commands.registerCommand(command, async (args) => { if (configuration.disableExtension) { @@ -571,7 +571,7 @@ export function registerCommand( context: vscode.ExtensionContext, command: string, callback: (...args: any[]) => any, - requiresActiveEditor: boolean = true + requiresActiveEditor: boolean = true, ) { const disposable = vscode.commands.registerCommand(command, async (args) => { if (requiresActiveEditor && !vscode.window.activeTextEditor) { @@ -588,7 +588,7 @@ export function registerEventListener( event: vscode.Event, listener: (e: T) => void, exitOnExtensionDisable = true, - exitOnTests = false + exitOnTests = false, ) { const disposable = event(async (e) => { if (exitOnExtensionDisable && configuration.disableExtension) { diff --git a/gulpfile.js b/gulpfile.js index 2b1b9a441..ed4197c82 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,14 +23,14 @@ function validateArgs(done) { return done( new PluginError('updateVersion', { message: 'Missing `--semver` option. Possible values: patch, minor, major', - }) + }), ); } if (!['patch', 'minor', 'major'].includes(options.semver)) { return done( new PluginError('updateVersion', { message: 'Invalid `--semver` option. Possible values: patch, minor, major', - }) + }), ); } @@ -65,18 +65,18 @@ function updatePath() { const filePath = f.path; let platformRelativepath = path.relative( path.dirname(filePath), - path.resolve(process.cwd(), 'out/src/platform/node') + path.resolve(process.cwd(), 'out/src/platform/node'), ); platformRelativepath = platformRelativepath.replace(/\\/g, '/'); f.contents = Buffer.from( contents.replace( /\(\"platform\/([^"]*)\"\)/g, - '("' + (platformRelativepath === '' ? './' : platformRelativepath + '/') + '$1")' + '("' + (platformRelativepath === '' ? './' : platformRelativepath + '/') + '$1")', ), - 'utf8' + 'utf8', ); return f; - }) + }), ); return es.duplex(input, output); } @@ -108,7 +108,7 @@ gulp.task('webpack', function () { config: webpack_config, entry: ['./extension.ts', './extensionWeb.ts'], }, - webpack + webpack, ).pipe(gulp.dest('out')); }); @@ -118,7 +118,7 @@ gulp.task('webpack-dev', function () { config: webpack_dev_config, entry: ['./extension.ts'], }, - webpack + webpack, ).pipe(gulp.dest('out')); }); @@ -148,7 +148,7 @@ gulp.task('run-test', function (done) { { cwd: process.cwd(), stdio: 'inherit', - } + }, ); dockerBuildCmd.on('exit', function (exitCode) { @@ -156,7 +156,7 @@ gulp.task('run-test', function (done) { return done( new PluginError('test', { message: 'Docker build failed.', - }) + }), ); } diff --git a/package.json b/package.json index fbe02a9a2..6b806107d 100644 --- a/package.json +++ b/package.json @@ -1184,7 +1184,7 @@ "minimist": "1.2.8", "mocha": "10.2.0", "plugin-error": "2.0.1", - "prettier": "2.8.8", + "prettier": "3.0.0", "sinon": "15.2.0", "ts-loader": "9.4.4", "tslint": "6.1.3", diff --git a/src/actions/base.ts b/src/actions/base.ts index e31012819..143a15aa7 100644 --- a/src/actions/base.ts +++ b/src/actions/base.ts @@ -95,7 +95,7 @@ export abstract class BaseAction implements IBaseAction { public static CompareKeypressSequence( one: readonly string[] | readonly string[][], - two: readonly string[] + two: readonly string[], ): boolean { if (BaseAction.is2DArray(one)) { for (const sequence of one) { @@ -206,7 +206,7 @@ export abstract class BaseCommand extends BaseAction { a.start.line > b.start.line || (a.start.line === b.start.line && a.start.character > b.start.character) ? 1 - : -1 + : -1, ); let cursorIndex = 0; @@ -255,7 +255,7 @@ const actionMap = new Map BaseAction>>(); */ export function getRelevantAction( keysPressed: string[], - vimState: VimState + vimState: VimState, ): BaseAction | KeypressState { const possibleActionsForMode = actionMap.get(vimState.currentMode) ?? []; diff --git a/src/actions/baseMotion.ts b/src/actions/baseMotion.ts index 6a12fc9bb..3ed6952cd 100644 --- a/src/actions/baseMotion.ts +++ b/src/actions/baseMotion.ts @@ -84,7 +84,7 @@ export abstract class BaseMovement extends BaseAction { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { throw new Error('Not implemented!'); } @@ -98,7 +98,7 @@ export abstract class BaseMovement extends BaseAction { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { return this.execAction(position, vimState, firstIteration, lastIteration); } @@ -111,7 +111,7 @@ export abstract class BaseMovement extends BaseAction { public async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { let result!: Position | IMovement; let prevResult = failedMovement(vimState); diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index dd2473d01..f8f6104db 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -85,7 +85,7 @@ export class DocumentContentChangeAction extends BaseCommand { const linesAffected = change.range.end.line - change.range.start.line + 1; const resultLines = change.text.split('\n').length; originalLeftBoundary = originalLeftBoundary.with( - Math.max(0, originalLeftBoundary.line + resultLines - linesAffected) + Math.max(0, originalLeftBoundary.line + resultLines - linesAffected), ); continue; } @@ -103,7 +103,7 @@ export class DocumentContentChangeAction extends BaseCommand { const replaceRange = new vscode.Range( translate(change.range.start), - translate(change.range.end) + translate(change.range.end), ); if (replaceRange.start.isAfter(rightBoundary)) { @@ -125,13 +125,13 @@ export class DocumentContentChangeAction extends BaseCommand { vimState.recordedState.transformer.insert( replaceRange.start, change.text, - PositionDiff.exactPosition(translate(this.cursorEnd)) + PositionDiff.exactPosition(translate(this.cursorEnd)), ); } else { vimState.recordedState.transformer.replace( replaceRange, change.text, - PositionDiff.exactPosition(translate(this.cursorEnd)) + PositionDiff.exactPosition(translate(this.cursorEnd)), ); } } @@ -140,7 +140,7 @@ export class DocumentContentChangeAction extends BaseCommand { private compressChanges(): void { function merge( first: vscode.TextDocumentContentChangeEvent, - second: vscode.TextDocumentContentChangeEvent + second: vscode.TextDocumentContentChangeEvent, ): vscode.TextDocumentContentChangeEvent | undefined { if (first.rangeOffset + first.text.length === second.rangeOffset) { // Simple concatenation @@ -400,7 +400,7 @@ class CommandExecuteMacro extends BaseCommand { if (!Register.isValidRegister(register) || isFilenameRegister) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.InvalidRegisterName, `'${register}'`) + VimError.fromCode(ErrorCode.InvalidRegisterName, `'${register}'`), ); } @@ -534,8 +534,8 @@ class CommandOverrideCopy extends BaseCommand { return vimState.document.getText( new vscode.Range( earlierOf(range.start.getLineBegin(), range.stop.getLineBegin()), - laterOf(range.start.getLineEnd(), range.stop.getLineEnd()) - ) + laterOf(range.start.getLineEnd(), range.stop.getLineEnd()), + ), ); }) .join('\n'); @@ -572,7 +572,7 @@ class CommandCmdA extends BaseCommand { vimState.cursorStartPosition = new Position(0, vimState.desiredColumn); vimState.cursorStopPosition = new Position( vimState.document.lineCount - 1, - vimState.desiredColumn + vimState.desiredColumn, ); await vimState.setCurrentMode(Mode.VisualLine); } @@ -677,13 +677,13 @@ export class CommandShowSearchHistory extends BaseCommand { const nextMatch = searchState.getNextSearchMatchPosition( vimState, vimState.cursorStartPosition, - this.direction + this.direction, ); if (!nextMatch) { throw VimError.fromCode( this.direction > 0 ? ErrorCode.SearchHitBottom : ErrorCode.SearchHitTop, - searchState.searchString + searchState.searchString, ); } @@ -757,11 +757,11 @@ class CommandGoToOtherSideOfHighlightedText extends BaseCommand { [vimState.cursorStartPosition, vimState.cursorStopPosition] = [ new vscode.Position( vimState.cursorStartPosition.line, - vimState.cursorStopPosition.character + vimState.cursorStopPosition.character, ), new vscode.Position( vimState.cursorStopPosition.line, - vimState.cursorStartPosition.character + vimState.cursorStartPosition.character, ), ]; } else { @@ -881,7 +881,7 @@ class CommandChangeToLineEnd extends BaseCommand { position .getDown(Math.max(0, count - 1)) .getLineEnd() - .getLeft() + .getLeft(), ); } } @@ -896,7 +896,7 @@ class CommandClearLine extends BaseCommand { await new operator.ChangeOperator(this.multicursorIndex).runRepeat( vimState, position, - vimState.recordedState.count || 1 + vimState.recordedState.count || 1, ); } @@ -1016,7 +1016,7 @@ class CommandOpenFile extends BaseCommand { } else { const range = new vscode.Range( position.prevWordStart(vimState.document, { wordType: WordType.FileName, inclusive: true }), - position.nextWordStart(vimState.document, { wordType: WordType.FileName }) + position.nextWordStart(vimState.document, { wordType: WordType.FileName }), ); fullFilePath = vimState.document.getText(range).trim(); @@ -1257,7 +1257,7 @@ export class CommandInsertNewLineBefore extends BaseCommand { for (let i = 1; i < count; i++) { const newPos = new Position( vimState.cursorStartPosition.line - i, - vimState.cursorStartPosition.character + vimState.cursorStartPosition.character, ); vimState.cursors.push(new Cursor(newPos, newPos)); @@ -1360,7 +1360,7 @@ export class ActionDeleteChar extends BaseCommand { await new operator.DeleteOperator(this.multicursorIndex).run( vimState, position, - position.getRight(timesToRepeat - 1).getLeftIfEOL() + position.getRight(timesToRepeat - 1).getLeftIfEOL(), ); await vimState.setCurrentMode(Mode.Normal); @@ -1409,7 +1409,7 @@ export class ActionDeleteLastChar extends BaseCommand { await new operator.DeleteOperator(this.multicursorIndex).run( vimState, position.getLeft(timesToRepeat), - position.getLeft() + position.getLeft(), ); } } @@ -1435,7 +1435,7 @@ class ActionJoin extends BaseCommand { startPosition: Position, position: Position, vimState: VimState, - count: number + count: number, ): Promise { count = count - 1 || 1; @@ -1531,7 +1531,7 @@ class ActionJoin extends BaseCommand { vimState.cursorStartPosition = vimState.cursorStopPosition = new Position( startPosition.line, - trimmedLinesContent.length - columnDeltaOffset + trimmedLinesContent.length - columnDeltaOffset, ); await vimState.setCurrentMode(Mode.Normal); } @@ -1545,7 +1545,7 @@ class ActionJoin extends BaseCommand { a.start.line > b.start.line || (a.start.line === b.start.line && a.start.character > b.start.character) ? 1 - : -1 + : -1, ); const resultingCursors: Cursor[] = []; @@ -1619,7 +1619,10 @@ class ActionJoinNoWhitespace extends BaseCommand { public async execJoin(count: number, position: Position, vimState: VimState): Promise { const replaceRange = new vscode.Range( new Position(position.line, 0), - new Position(Math.min(position.line + count, vimState.document.lineCount - 1), 0).getLineEnd() + new Position( + Math.min(position.line + count, vimState.document.lineCount - 1), + 0, + ).getLineEnd(), ); const joinedText = vimState.document.getText(replaceRange).replace(/\r?\n/g, ''); @@ -1693,7 +1696,7 @@ class ActionReplaceCharacter extends BaseCommand { vimState.recordedState.transformer.vscodeCommand('tab'); vimState.recordedState.transformer.moveCursor( PositionDiff.offset({ character: -1 }), - this.multicursorIndex + this.multicursorIndex, ); } else if (toReplace === '\n') { // A newline replacement always inserts exactly one newline (regardless @@ -1774,7 +1777,7 @@ class ActionReplaceCharacterVisual extends BaseCommand { text: Array(end.character + 1 + visualSelectionOffset).join(toInsert), range: new vscode.Range( new Position(end.line, 0), - new Position(end.line, end.character + visualSelectionOffset) + new Position(end.line, end.character + visualSelectionOffset), ), manuallySetCursorPositions: true, }); @@ -1826,7 +1829,7 @@ class ActionReplaceCharacterVisualBlock extends BaseCommand { const topLeft = visualBlockGetTopLeftPosition( vimState.cursorStopPosition, - vimState.cursorStartPosition + vimState.cursorStartPosition, ); vimState.cursors = [new Cursor(topLeft, topLeft)]; await vimState.setCurrentMode(Mode.Normal); @@ -1860,7 +1863,7 @@ class ActionDeleteVisualBlock extends BaseCommand { const topLeft = visualBlockGetTopLeftPosition( vimState.cursorStopPosition, - vimState.cursorStartPosition + vimState.cursorStartPosition, ); vimState.cursors = [new Cursor(topLeft, topLeft)]; @@ -1891,7 +1894,7 @@ class ActionShiftDVisualBlock extends BaseCommand { const topLeft = visualBlockGetTopLeftPosition( vimState.cursorStopPosition, - vimState.cursorStartPosition + vimState.cursorStartPosition, ); const text = lines.length === 1 ? lines[0] : lines.join('\n'); @@ -1997,7 +2000,7 @@ abstract class ActionGoToInsertVisualLineModeCommand extends BaseCommand { abstract getCursorRangeForLine( line: vscode.TextLine, selectionStart: Position, - selectionEnd: Position + selectionEnd: Position, ): Cursor; public override async exec(position: Position, vimState: VimState): Promise { @@ -2037,7 +2040,7 @@ class ActionGoToInsertVisualLineMode extends ActionGoToInsertVisualLineModeComma getCursorRangeForLine(line: vscode.TextLine): Cursor { const startCharacterPosition = new Position( line.lineNumber, - line.firstNonWhitespaceCharacterIndex + line.firstNonWhitespaceCharacterIndex, ); return new Cursor(startCharacterPosition, startCharacterPosition); } @@ -2062,7 +2065,7 @@ class ActionGoToInsertVisualMode extends ActionGoToInsertVisualLineModeCommand { getCursorRangeForLine( line: vscode.TextLine, selectionStart: Position, - selectionEnd: Position + selectionEnd: Position, ): Cursor { const startCharacterPosition = line.lineNumber === selectionStart.line @@ -2080,7 +2083,7 @@ class ActionGoToInsertVisualModeAppend extends ActionGoToInsertVisualLineModeCom getCursorRangeForLine( line: vscode.TextLine, selectionStart: Position, - selectionEnd: Position + selectionEnd: Position, ): Cursor { const endCharacterPosition = line.lineNumber === selectionEnd.line @@ -2113,7 +2116,7 @@ class ActionGoToInsertVisualBlockModeAppend extends BaseCommand { vimState.editor, ' '.repeat(insertionColumn - line.text.length), line.range.end, - false + false, ); } const newCursor = new Position(lineNum, insertionColumn); @@ -2138,7 +2141,7 @@ export class ActionDeleteCharVisualLineMode extends BaseCommand { await new operator.DeleteOperator(this.multicursorIndex).run( vimState, start.getLineBegin(), - end.getLineEnd() + end.getLineEnd(), ); } } @@ -2153,7 +2156,7 @@ class ActionDeleteLineVisualMode extends BaseCommand { await new operator.DeleteOperator(this.multicursorIndex).run( vimState, start.getLineBegin(), - end.getLineEnd() + end.getLineEnd(), ); } } @@ -2182,7 +2185,7 @@ class ActionChangeLineVisualMode extends BaseCommand { await new operator.ChangeOperator(this.multicursorIndex).run( vimState, start.getLineBegin(), - end.getLineEnd().getLeftIfEOL() + end.getLineEnd().getLeftIfEOL(), ); } } @@ -2206,7 +2209,7 @@ class ActionChangeChar extends BaseCommand { await new operator.ChangeOperator(this.multicursorIndex).run( vimState, position, - position.getRight((vimState.recordedState.count || 1) - 1) + position.getRight((vimState.recordedState.count || 1) - 1), ); } @@ -2252,7 +2255,7 @@ class ToggleCaseAndMoveForward extends BaseCommand { position, shouldWrapKey(vimState.currentMode, '~') ? position.getOffsetThroughLineBreaks(count) - : position.getRight(count) + : position.getRight(count), ); vimState.recordedState.transformer.addTransformation({ @@ -2294,7 +2297,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { wordLoop: for (let { start, end, word } of TextEditor.iterateWords( vimState.document, - whereToStart + whereToStart, )) { if (start.isAfter(range.stop)) { break; @@ -2321,7 +2324,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { num, this.offset * stepNum * (vimState.recordedState.count || 1), start, - end + end, ); if (this.staircase) { @@ -2330,7 +2333,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { if (vimState.currentMode === Mode.Normal) { vimState.recordedState.transformer.moveCursor( - PositionDiff.exactPosition(pos.getLeft(num.suffix.length)) + PositionDiff.exactPosition(pos.getLeft(num.suffix.length)), ); } break wordLoop; @@ -2355,7 +2358,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { start: NumericString, offset: number, startPos: Position, - endPos: Position + endPos: Position, ): Promise { const oldLength = endPos.character + 1 - startPos.character; start.value += offset; @@ -2381,7 +2384,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { switch (vimState.currentMode) { case Mode.Normal: { ranges.push( - new Cursor(vimState.cursorStopPosition, vimState.cursorStopPosition.getLineEnd()) + new Cursor(vimState.cursorStopPosition, vimState.cursorStopPosition.getLineEnd()), ); break; } @@ -2411,8 +2414,8 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { ranges.push( new Cursor( new Position(line, topLeft.character), - new Position(line, bottomRight.character) - ) + new Position(line, bottomRight.character), + ), ); } break; @@ -2420,7 +2423,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { default: throw new Error( - `Unexpected mode ${vimState.currentMode} in IncrementDecrementNumberAction.getPositions()` + `Unexpected mode ${vimState.currentMode} in IncrementDecrementNumberAction.getPositions()`, ); } return ranges; @@ -2469,7 +2472,7 @@ export class CommandUnicodeName extends BaseCommand { // TODO: Handle charCode > 127 by also including StatusBar.setText( vimState, - `<${char}> ${charCode}, Hex ${charCode.toString(16)}, Octal ${charCode.toString(8)}` + `<${char}> ${charCode}, Hex ${charCode.toString(16)}, Octal ${charCode.toString(8)}`, ); } } @@ -2537,7 +2540,7 @@ class ActionOverrideCmdDInsert extends BaseCommand { if (idx === 0) { return new vscode.Selection( curPos.prevWordStart(vimState.document), - curPos.getLeft().nextWordEnd(vimState.document, { inclusive: true }).getRight() + curPos.getLeft().nextWordEnd(vimState.document, { inclusive: true }).getRight(), ); } else { // Since we're adding the selections ourselves, we need to make sure diff --git a/src/actions/commands/commandLine.ts b/src/actions/commands/commandLine.ts index da21a9824..5da3487bc 100644 --- a/src/actions/commands/commandLine.ts +++ b/src/actions/commands/commandLine.ts @@ -119,11 +119,11 @@ class CommandLineTab extends CommandLineAction { p.sep, currentUri, isRemote, - shouldAddDotItems + shouldAddDotItems, ); const startWithBaseNameRegex = new RegExp( `^${baseName}`, - process.platform === 'win32' ? 'i' : '' + process.platform === 'win32' ? 'i' : '', ); newCompletionItems = dirItems .map((name): [RegExpExecArray | null, string] => [startWithBaseNameRegex.exec(name), name]) @@ -298,7 +298,7 @@ class CommandInsertRegisterContentInCommandLine extends CommandLineAction { if (register === undefined) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName) + VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName), ); return; } diff --git a/src/actions/commands/insert.ts b/src/actions/commands/insert.ts index efac0fa5b..cebf0ae7b 100644 --- a/src/actions/commands/insert.ts +++ b/src/actions/commands/insert.ts @@ -77,7 +77,7 @@ export class CommandEscInsertMode extends BaseCommand { a instanceof CommandInsertAtLineBegin || a instanceof CommandInsertAtLineEnd || a instanceof CommandInsertAtFirstCharacter || - a instanceof CommandInsertAtLastChange + a instanceof CommandInsertAtLastChange, ) !== undefined; // If this is the type to repeat insert, do this now @@ -98,7 +98,7 @@ export class CommandEscInsertMode extends BaseCommand { // Add a transform containing the change vimState.recordedState.transformer.addTransformation( - changeAction.getTransformation(positionDiff) + changeAction.getTransformation(positionDiff), ); } } @@ -177,13 +177,13 @@ abstract class IndentCommand extends BaseCommand { vimState.recordedState.transformer.replace( new vscode.Range( position.getLineBegin(), - position.with({ character: line.firstNonWhitespaceCharacterIndex }) + position.with({ character: line.firstNonWhitespaceCharacterIndex }), ), TextEditor.setIndentationLevel( line.text, newIndentationWidth, - vimState.editor.options.insertSpaces as boolean - ).match(/^(\s*)/)![1] + vimState.editor.options.insertSpaces as boolean, + ).match(/^(\s*)/)![1], ); } } @@ -342,7 +342,7 @@ class CommandInsertRegisterContent extends BaseCommand { if (register === undefined) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.NothingInRegister, this.keysPressed[1]) + VimError.fromCode(ErrorCode.NothingInRegister, this.keysPressed[1]), ); return; } @@ -530,7 +530,7 @@ class NewLineInsertMode extends BaseCommand { vimState.recordedState.transformer.insert( position, '\n', - PositionDiff.offset({ character: -1 }) + PositionDiff.offset({ character: -1 }), ); } } diff --git a/src/actions/commands/put.ts b/src/actions/commands/put.ts index 198a5fca2..4c7ffa1fe 100644 --- a/src/actions/commands/put.ts +++ b/src/actions/commands/put.ts @@ -29,7 +29,7 @@ abstract class BasePutCommand extends BaseCommand { if (register === undefined) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName) + VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName), ); return; } @@ -57,7 +57,7 @@ abstract class BasePutCommand extends BaseCommand { } text = this.adjustIndent( lineToMatch !== undefined ? vimState.document.lineAt(lineToMatch).text : '', - text + text, ); } @@ -67,12 +67,12 @@ abstract class BasePutCommand extends BaseCommand { replaceRange, registerMode, count, - text + text, ); vimState.recordedState.transformer.moveCursor( PositionDiff.exactPosition(newCursorPosition), - this.multicursorIndex ?? 0 + this.multicursorIndex ?? 0, ); if (registerMode === RegisterMode.LineWise) { @@ -84,7 +84,7 @@ abstract class BasePutCommand extends BaseCommand { mode, replaceRange, registerMode, - text + text, )) { vimState.recordedState.transformer.addTransformation(transformation); } @@ -104,7 +104,7 @@ abstract class BasePutCommand extends BaseCommand { vimState, vimState.document.getText(replaceRange), this.multicursorIndex, - true + true, ); } } @@ -178,7 +178,7 @@ abstract class BasePutCommand extends BaseCommand { mode: Mode, replaceRange: vscode.Range, registerMode: RegisterMode, - text: string + text: string, ): Transformation[] { // Pasting block-wise content is very different, except in VisualLine mode, where it works exactly like line-wise if (registerMode === RegisterMode.BlockWise && mode !== Mode.VisualLine) { @@ -202,7 +202,7 @@ abstract class BasePutCommand extends BaseCommand { } else { range = new vscode.Range( replaceRange.start.with({ line: replaceRange.start.line + idx }), - replaceRange.end.with({ line: replaceRange.start.line + idx }) + replaceRange.end.with({ line: replaceRange.start.line + idx }), ); } } else { @@ -259,7 +259,7 @@ abstract class BasePutCommand extends BaseCommand { for (let line = replaceRange.start.line; line <= replaceRange.end.line; line++) { const range = new vscode.Range( new Position(line, replaceRange.start.character), - new Position(line, replaceRange.end.character) + new Position(line, replaceRange.end.character), ); const lineText = !text.includes('\n') || line === replaceRange.start.line ? text : ''; transformations.push({ @@ -273,7 +273,7 @@ abstract class BasePutCommand extends BaseCommand { for (let line = replaceRange.start.line; line <= replaceRange.end.line; line++) { const range = new vscode.Range( new Position(line, replaceRange.start.character), - new Position(line, replaceRange.end.character) + new Position(line, replaceRange.end.character), ); transformations.push({ type: 'replaceText', @@ -307,7 +307,7 @@ abstract class BasePutCommand extends BaseCommand { protected abstract getReplaceRange( mode: Mode, cursor: Cursor, - registerMode: RegisterMode + registerMode: RegisterMode, ): vscode.Range; protected abstract adjustLinewiseRegisterText(mode: Mode, text: string): string; @@ -320,7 +320,7 @@ abstract class BasePutCommand extends BaseCommand { replaceRange: vscode.Range, registerMode: RegisterMode, count: number, - text: string + text: string, ): Position; } @@ -379,7 +379,7 @@ class PutCommand extends BasePutCommand { replaceRange: vscode.Range, registerMode: RegisterMode, count: number, - text: string + text: string, ): Position { const rangeStart = replaceRange.start; if (mode === Mode.Normal || mode === Mode.Visual) { @@ -430,7 +430,7 @@ class PutBeforeCommand extends PutCommand { protected override getReplaceRange( mode: Mode, cursor: Cursor, - registerMode: RegisterMode + registerMode: RegisterMode, ): vscode.Range { if (mode === Mode.Normal) { if (registerMode === RegisterMode.CharacterWise || registerMode === RegisterMode.BlockWise) { @@ -451,7 +451,7 @@ class PutBeforeCommand extends PutCommand { replaceRange: vscode.Range, registerMode: RegisterMode, count: number, - text: string + text: string, ): Position { const rangeStart = replaceRange.start; if (mode === Mode.Normal || mode === Mode.VisualBlock) { @@ -472,7 +472,7 @@ function PlaceCursorAfterText PutCommand>( replaceRange: vscode.Range, registerMode: RegisterMode, count: number, - text: string + text: string, ): Position { const rangeStart = replaceRange.start; if (mode === Mode.Normal || mode === Mode.Visual) { @@ -511,7 +511,7 @@ function PlaceCursorAfterText PutCommand>( } else if (registerMode === RegisterMode.BlockWise) { return new Position( replaceRange.start.line + lines.length - 1, - replaceRange.start.character + lines[lines.length - 1].length + replaceRange.start.character + lines[lines.length - 1].length, ); } else { return rangeStart.with({ character: rangeStart.character + text.length }); @@ -577,7 +577,7 @@ function ExCommand PutCommand>(Base: TBase protected override getReplaceRange( mode: Mode, cursor: Cursor, - registerMode: RegisterMode + registerMode: RegisterMode, ): vscode.Range { const line = this.insertLine ?? laterOf(cursor.start, cursor.stop).line; const pos = this.putBefore() ? new Position(line, 0) : new Position(line, 0).getLineEnd(); @@ -590,12 +590,12 @@ function ExCommand PutCommand>(Base: TBase replaceRange: vscode.Range, registerMode: RegisterMode, count: number, - text: string + text: string, ): Position { const lines = text.split('\n'); return new Position( replaceRange.start.line + lines.length - (this.putBefore() ? 1 : 0), - firstNonBlankChar(lines[lines.length - 1]) + firstNonBlankChar(lines[lines.length - 1]), ); } }; diff --git a/src/actions/commands/replace.ts b/src/actions/commands/replace.ts index c74a28809..fd3726f10 100644 --- a/src/actions/commands/replace.ts +++ b/src/actions/commands/replace.ts @@ -27,7 +27,7 @@ class ExitReplaceMode extends BaseCommand { .repeat(timesToRepeat - 1); vimState.recordedState.transformer.replace( new Range(position, position.getRight(newText.length)), - newText + newText, ); } else { vimState.cursorStopPosition = vimState.cursorStopPosition.getLeft(); diff --git a/src/actions/commands/scroll.ts b/src/actions/commands/scroll.ts index 5d59ef6e8..df7a9c2ad 100644 --- a/src/actions/commands/scroll.ts +++ b/src/actions/commands/scroll.ts @@ -98,7 +98,7 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand { // This makes less wonky when `editor.scrollBeyondLastLine` is enabled scrollLines = Math.min( moveLines, - vimState.document.lineCount - 1 - visibleRanges[visibleRanges.length - 1].end.line + vimState.document.lineCount - 1 - visibleRanges[visibleRanges.length - 1].end.line, ); } @@ -123,11 +123,11 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand { const newPositionLine = clamp( position.line + (this.to === 'down' ? moveLines : -moveLines), 0, - vimState.document.lineCount - 1 + vimState.document.lineCount - 1, ); vimState.cursorStopPosition = new Position( newPositionLine, - vimState.desiredColumn + vimState.desiredColumn, ).obeyStartOfLine(vimState.document); } } @@ -190,7 +190,7 @@ class CommandCenterScroll extends BaseCommand { // In these modes you want to center on the cursor position vimState.editor.revealRange( new vscode.Range(vimState.cursorStopPosition, vimState.cursorStopPosition), - vscode.TextEditorRevealType.InCenter + vscode.TextEditorRevealType.InCenter, ); } } @@ -212,13 +212,13 @@ class CommandCenterScrollFirstChar extends BaseCommand { // This particular one moves cursor to first non blank char though vimState.editor.revealRange( new vscode.Range(vimState.cursorStopPosition, vimState.cursorStopPosition), - vscode.TextEditorRevealType.InCenter + vscode.TextEditorRevealType.InCenter, ); // Move cursor to first char of line vimState.cursorStopPosition = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - vimState.cursorStopPosition.line + vimState.cursorStopPosition.line, ); } } @@ -274,7 +274,7 @@ class CommandTopScrollFirstChar extends BaseCommand { // Move cursor to first char of line vimState.cursorStopPosition = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - vimState.cursorStopPosition.line + vimState.cursorStopPosition.line, ); } } @@ -330,7 +330,7 @@ class CommandBottomScrollFirstChar extends BaseCommand { // Move cursor to first char of line vimState.cursorStopPosition = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - vimState.cursorStopPosition.line + vimState.cursorStopPosition.line, ); } } diff --git a/src/actions/commands/search.ts b/src/actions/commands/search.ts index f1f262925..6807d7257 100644 --- a/src/actions/commands/search.ts +++ b/src/actions/commands/search.ts @@ -25,7 +25,7 @@ async function searchCurrentWord( position: Position, vimState: VimState, direction: SearchDirection, - isExact: boolean + isExact: boolean, ): Promise { let currentWord = TextEditor.getWord(vimState.document, position); @@ -107,7 +107,7 @@ async function createSearchStateAndMoveToMatch(args: { args.direction, vimState.cursorStopPosition, searchString, - { ignoreSmartcase: true } + { ignoreSmartcase: true }, ); Register.setReadonlyRegister('/', globalState.searchState.searchString); SearchCommandLine.addSearchStateToHistory(globalState.searchState); @@ -117,7 +117,7 @@ async function createSearchStateAndMoveToMatch(args: { const nextMatch = globalState.searchState.getNextSearchMatchPosition( vimState, - args.searchStartCursorPosition + args.searchStartCursorPosition, ); if (nextMatch) { vimState.cursorStopPosition = nextMatch.pos; @@ -125,7 +125,7 @@ async function createSearchStateAndMoveToMatch(args: { reportSearch( nextMatch.index, globalState.searchState.getMatchRanges(vimState).length, - vimState + vimState, ); } else { StatusBar.displayError( @@ -134,8 +134,8 @@ async function createSearchStateAndMoveToMatch(args: { args.direction === SearchDirection.Forward ? ErrorCode.SearchHitBottom : ErrorCode.SearchHitTop, - globalState.searchState.searchString - ) + globalState.searchState.searchString, + ), ); } } @@ -249,7 +249,7 @@ abstract class SearchObject extends TextObject { this.direction, vimState.cursorStopPosition, searchState.searchString, - {} + {}, ); // At first, try to search for current word, and stop searching if matched. @@ -294,7 +294,7 @@ abstract class SearchObject extends TextObject { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { return this.execAction(position, vimState); } diff --git a/src/actions/languages/python/motion.ts b/src/actions/languages/python/motion.ts index 52f918da2..a8a7d417a 100755 --- a/src/actions/languages/python/motion.ts +++ b/src/actions/languages/python/motion.ts @@ -127,7 +127,7 @@ export class PythonDocument { // Calculate position of last non-white character) end: new Position( endLine.line, - endLine.text.search(PythonDocument.reLastNonWhiteSpaceCharacter) - 1 + endLine.text.search(PythonDocument.reLastNonWhiteSpaceCharacter) - 1, ), }); } @@ -181,7 +181,7 @@ export class PythonDocument { position: Position, vimState: VimState, forward: boolean, - start: boolean + start: boolean, ): Position | IMovement { const direction = forward ? 'next' : 'prev'; const edge = start ? 'start' : 'end'; @@ -207,7 +207,7 @@ abstract class BasePythonMovement extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const document = vimState.document; return ( diff --git a/src/actions/motion.ts b/src/actions/motion.ts index 4d4d7fd41..5b9869f56 100755 --- a/src/actions/motion.ts +++ b/src/actions/motion.ts @@ -58,7 +58,7 @@ abstract class MoveByScreenLine extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { const multicursorIndex = this.multicursorIndex ?? 0; @@ -133,7 +133,7 @@ abstract class MoveByScreenLine extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const multicursorIndex = this.multicursorIndex ?? 0; if (multicursorIndex === 0) { @@ -184,7 +184,7 @@ abstract class MoveByScreenLineMaintainDesiredColumn extends MoveByScreenLine { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const prevDesiredColumn = vimState.desiredColumn; const prevLine = vimState.editor.selection.active.line; @@ -316,7 +316,7 @@ class MoveDown extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return position.getDown(); @@ -354,7 +354,7 @@ class MoveUp extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return position.getUp(); @@ -454,7 +454,7 @@ class ArrowsInReplaceMode extends BaseMovement { throw new Error(`Unexpected 'arrow' key: ${this.keys[0]}`); } (vimState.modeData as ModeDataFor).replaceState.resetChanges( - this.multicursorIndex ?? 0 + this.multicursorIndex ?? 0, ); return newPosition; } @@ -467,7 +467,7 @@ class CommandNextSearchMatch extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const searchState = globalState.searchState; @@ -481,7 +481,7 @@ class CommandNextSearchMatch extends BaseMovement { if (searchState.getMatchRanges(vimState).length === 0) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.PatternNotFound, searchState.searchString) + VimError.fromCode(ErrorCode.PatternNotFound, searchState.searchString), ); return failedMovement(vimState); } @@ -503,8 +503,8 @@ class CommandNextSearchMatch extends BaseMovement { searchState.direction === SearchDirection.Forward ? ErrorCode.SearchHitBottom : ErrorCode.SearchHitTop, - searchState.searchString - ) + searchState.searchString, + ), ); return failedMovement(vimState); } @@ -522,7 +522,7 @@ class CommandPreviousSearchMatch extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const searchState = globalState.searchState; @@ -536,7 +536,7 @@ class CommandPreviousSearchMatch extends BaseMovement { if (searchState.getMatchRanges(vimState).length === 0) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.PatternNotFound, searchState.searchString) + VimError.fromCode(ErrorCode.PatternNotFound, searchState.searchString), ); return failedMovement(vimState); } @@ -550,7 +550,7 @@ class CommandPreviousSearchMatch extends BaseMovement { ? searchState.getNextSearchMatchPosition( vimState, position.getRight(), - SearchDirection.Backward + SearchDirection.Backward, ) : searchState.getNextSearchMatchPosition(vimState, position, SearchDirection.Backward); @@ -561,8 +561,8 @@ class CommandPreviousSearchMatch extends BaseMovement { searchState.direction === SearchDirection.Forward ? ErrorCode.SearchHitTop : ErrorCode.SearchHitBottom, - searchState.searchString - ) + searchState.searchString, + ), ); return failedMovement(vimState); } @@ -715,7 +715,7 @@ class MoveLeft extends BaseMovement { }; return shouldWrapKey(vimState.currentMode, this.keysPressed[0]) ? position.getLeftThroughLineBreaks( - [Mode.Insert, Mode.Replace].includes(vimState.currentMode) + [Mode.Insert, Mode.Replace].includes(vimState.currentMode), ) : getLeftWhile(position); } @@ -743,7 +743,7 @@ class MoveRight extends BaseMovement { }; return shouldWrapKey(vimState.currentMode, this.keysPressed[0]) ? position.getRightThroughLineBreaks( - [Mode.Insert, Mode.Replace].includes(vimState.currentMode) + [Mode.Insert, Mode.Replace].includes(vimState.currentMode), ) : getRightWhile(position); } @@ -756,12 +756,12 @@ class MoveDownNonBlank extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - position.getDown(Math.max(count, 1)).line + position.getDown(Math.max(count, 1)).line, ); } } @@ -773,12 +773,12 @@ class MoveUpNonBlank extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - position.getUp(Math.max(count, 1)).line + position.getUp(Math.max(count, 1)).line, ); } } @@ -790,7 +790,7 @@ class MoveDownUnderscore extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; const pos = position.getDown(Math.max(count - 1, 0)); @@ -807,7 +807,7 @@ class MoveToColumn extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { return new Position(position.line, Math.max(0, count - 1)); } @@ -824,7 +824,7 @@ function findHelper( start: Position, char: string, count: number, - direction: 'forward' | 'backward' + direction: 'forward' | 'backward', ): Position | undefined { const line = vimState.document.lineAt(start); @@ -852,12 +852,12 @@ class MoveFindForward extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { if (configuration.sneakReplacesF) { const pos = await new SneakForward( this.keysPressed.concat('\n'), - this.isRepeat + this.isRepeat, ).execActionWithCount(position, vimState, count); if (vimState.recordedState.operator && !isIMovement(pos)) { return pos.getRight(); @@ -892,13 +892,13 @@ class MoveFindBackward extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { if (configuration.sneakReplacesF) { return new SneakBackward(this.keysPressed.concat('\n'), this.isRepeat).execActionWithCount( position, vimState, - count + count, ); } @@ -922,7 +922,7 @@ function tilHelper( start: Position, char: string, count: number, - direction: 'forward' | 'backward' + direction: 'forward' | 'backward', ) { const result = findHelper(vimState, start, char, count, direction); return direction === 'forward' ? result?.getLeft() : result?.getRight(); @@ -935,7 +935,7 @@ class MoveTilForward extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { count ||= 1; const toFind = Notation.ToControlCharacter(this.keysPressed[1]); @@ -968,7 +968,7 @@ class MoveTilBackward extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { count ||= 1; const toFind = Notation.ToControlCharacter(this.keysPressed[1]); @@ -997,7 +997,7 @@ class MoveRepeat extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { const movement = vimState.lastSemicolonRepeatableMovement; if (movement) { @@ -1014,7 +1014,7 @@ class MoveRepeatReversed extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { const semiColonMovement = vimState.lastSemicolonRepeatableMovement; const commaMovement = vimState.lastCommaRepeatableMovement; @@ -1040,7 +1040,7 @@ class MoveLineEnd extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { return position.getDown(Math.max(count - 1, 0)).getLineEnd(); } @@ -1089,7 +1089,7 @@ class MoveScreenLineEndNonBlank extends MoveByScreenLine { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { count ||= 1; const pos = await super.execActionWithCount(position, vimState, count); @@ -1173,7 +1173,7 @@ class MoveUpByScreenLineVisualBlock extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { if (position.line > 0) { return position.with({ character: vimState.desiredColumn }).getUp(); @@ -1184,7 +1184,7 @@ class MoveUpByScreenLineVisualBlock extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return position.getUp(); @@ -1202,7 +1202,7 @@ class MoveDownByScreenLineVisualBlock extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { if (position.line < vimState.document.lineCount - 1) { return position.with({ character: vimState.desiredColumn }).getDown(); @@ -1213,7 +1213,7 @@ class MoveDownByScreenLineVisualBlock extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; return position.getDown(); @@ -1328,7 +1328,7 @@ class MoveNonBlankFirst extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; @@ -1349,19 +1349,19 @@ class MoveNonBlankLast extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; let stop: Position; if (count === 0) { stop = new Position(vimState.document.lineCount - 1, position.character).obeyStartOfLine( - vimState.document + vimState.document, ); } else { stop = new Position( Math.min(count, vimState.document.lineCount) - 1, - position.character + position.character, ).obeyStartOfLine(vimState.document); } @@ -1379,7 +1379,7 @@ class EndOfSpecificLine extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { const line = count ? clamp(count - 1, 0, vimState.document.lineCount - 1) @@ -1397,7 +1397,7 @@ export class MoveWordBegin extends BaseMovement { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { if ( lastIteration && @@ -1433,7 +1433,7 @@ export class MoveWordBegin extends BaseMovement { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { const result = await this.execAction(position, vimState, firstIteration, lastIteration); @@ -1492,7 +1492,7 @@ class MoveWordEnd extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const end = position.nextWordEnd(vimState.document); @@ -1510,7 +1510,7 @@ class MoveFullWordEnd extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { return position.nextWordEnd(vimState.document, { wordType: WordType.Big }).getRight(); } @@ -1654,7 +1654,7 @@ abstract class MoveSectionBoundary extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const document = vimState.document; @@ -1665,7 +1665,7 @@ abstract class MoveSectionBoundary extends BaseMovement { position, vimState, this.forward, - this.begin + this.begin, ); } @@ -1736,7 +1736,7 @@ class MoveToMatchingBracket extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { position = position.getLeftIfEOL(); @@ -1756,7 +1756,7 @@ class MoveToMatchingBracket extends BaseMovement { new Position(position.line, col), lineText[col], vimState, - false + false, ) || failure ); } @@ -1768,7 +1768,7 @@ class MoveToMatchingBracket extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const result = await this.execAction(position, vimState); @@ -1793,7 +1793,7 @@ class MoveToMatchingBracket extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { // % has a special mode that lets you use it to jump to a percentage of the file // However, some other bracket motions inherit from this so only do this behavior for % explicitly @@ -1833,7 +1833,7 @@ export abstract class MoveInsideCharacter extends ExpandingSelection { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { const closingChar = PairMatcher.pairings[this.charToMatch].match; const [selStart, selEnd] = sorted(vimState.cursorStartPosition, position); @@ -1941,7 +1941,7 @@ export abstract class MoveCurlyBrace extends MoveInsideCharacter { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { // curly braces has a special treatment. In case the cursor is before an opening curly brace, // and there are no characters before the opening curly brace in the same line, it should jump @@ -1956,7 +1956,7 @@ export abstract class MoveCurlyBrace extends MoveInsideCharacter { ) { const curlyPos = position.with( position.line, - position.character + openCurlyBraceIndexFromCursor + position.character + openCurlyBraceIndexFromCursor, ); vimState.cursorStartPosition = vimState.cursorStopPosition = curlyPos; const movement = await super.execAction(curlyPos, vimState, firstIteration, lastIteration); @@ -2060,7 +2060,7 @@ export abstract class MoveQuoteMatch extends BaseMovement { public override async execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise { // TODO: this is super janky return (await super.execActionWithCount(position, vimState, 1)) as IMovement; @@ -2080,7 +2080,7 @@ export abstract class MoveQuoteMatch extends BaseMovement { if (useSmartQuotes()) { const quoteMatcher = new SmartQuoteMatcher( this.anyQuote ? 'any' : this.charToMatch, - vimState.document + vimState.document, ); const res = quoteMatcher.smartSurroundingQuotes(position, this.which); @@ -2164,7 +2164,7 @@ export abstract class MoveQuoteMatch extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const result = await this.execAction(position, vimState); if (isIMovement(result)) { @@ -2227,7 +2227,7 @@ class MoveToUnclosedRoundBracketBackward extends MoveToMatchingBracket { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const charToMatch = ')'; const result = PairMatcher.nextPairedChar(position, charToMatch, vimState, false); @@ -2245,7 +2245,7 @@ class MoveToUnclosedRoundBracketForward extends MoveToMatchingBracket { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const charToMatch = '('; const result = PairMatcher.nextPairedChar(position, charToMatch, vimState, false); @@ -2272,7 +2272,7 @@ class MoveToUnclosedCurlyBracketBackward extends MoveToMatchingBracket { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const charToMatch = '}'; const result = PairMatcher.nextPairedChar(position, charToMatch, vimState, false); @@ -2290,7 +2290,7 @@ class MoveToUnclosedCurlyBracketForward extends MoveToMatchingBracket { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const charToMatch = '{'; const result = PairMatcher.nextPairedChar(position, charToMatch, vimState, false); diff --git a/src/actions/operator.ts b/src/actions/operator.ts index 7a5cf4fc4..b93668d49 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -77,7 +77,7 @@ export abstract class BaseOperator extends BaseAction { await this.run( vimState, position.getLineBegin(), - position.getDown(Math.max(0, count - 1)).getLineEnd() + position.getDown(Math.max(0, count - 1)).getLineEnd(), ); } @@ -344,7 +344,7 @@ abstract class ChangeCaseOperator extends BaseOperator { const range = new vscode.Range(start, end); vimState.recordedState.transformer.replace( range, - this.transformText(vimState.document.getText(range)) + this.transformText(vimState.document.getText(range)), ); } @@ -352,7 +352,7 @@ abstract class ChangeCaseOperator extends BaseOperator { for (let i = 0; i < vimState.editor.selections.length; i++) { vimState.recordedState.transformer.moveCursor( PositionDiff.exactPosition(earlierOf(startPos, endPos)), - i + i, ); } } else { @@ -495,7 +495,7 @@ class IndentOperatorVisualBlock extends BaseOperator { if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) { const shiftSelectionByNum = Math.abs( vimState.dotCommandPreviousVisualSelection.end.line - - vimState.dotCommandPreviousVisualSelection.start.line + vimState.dotCommandPreviousVisualSelection.start.line, ); start = vimState.cursorStartPosition; @@ -534,7 +534,7 @@ class OutdentOperator extends BaseOperator { await vimState.setCurrentMode(Mode.Normal); vimState.cursorStopPosition = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - start.line + start.line, ); } } @@ -569,7 +569,7 @@ class OutdentOperatorVisualAndVisualLine extends BaseOperator { await vimState.setCurrentMode(Mode.Normal); vimState.cursorStopPosition = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - start.line + start.line, ); } } @@ -588,7 +588,7 @@ class OutdentOperatorVisualBlock extends BaseOperator { if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) { const shiftSelectionByNum = Math.abs( vimState.dotCommandPreviousVisualSelection.end.line - - vimState.dotCommandPreviousVisualSelection.start.line + vimState.dotCommandPreviousVisualSelection.start.line, ); start = vimState.cursorStartPosition; @@ -611,7 +611,7 @@ class OutdentOperatorVisualBlock extends BaseOperator { const distToNonBlankChar = currentLineFromStart.match(/\S/)?.index ?? 0; const outdentDist = Math.min( distToNonBlankChar, - tabSize * (vimState.recordedState.count || 1) + tabSize * (vimState.recordedState.count || 1), ); vimState.recordedState.transformer.addTransformation({ @@ -654,21 +654,21 @@ export class ChangeOperator extends BaseOperator { const firstLineIndent = vimState.document.getText( new vscode.Range( deleteRange.start.getLineBegin(), - deleteRange.start.getLineBeginRespectingIndent(vimState.document) - ) + deleteRange.start.getLineBeginRespectingIndent(vimState.document), + ), ); vimState.recordedState.transformer.replace( deleteRange, firstLineIndent, - PositionDiff.exactPosition(new Position(deleteRange.start.line, firstLineIndent.length)) + PositionDiff.exactPosition(new Position(deleteRange.start.line, firstLineIndent.length)), ); if (vimState.document.languageId !== 'plaintext') { vimState.recordedState.transformer.vscodeCommand('editor.action.reindentselectedlines'); vimState.recordedState.transformer.moveCursor( PositionDiff.endOfLine(), - this.multicursorIndex + this.multicursorIndex, ); } } else { @@ -1024,7 +1024,7 @@ class ActionVisualReflowParagraph extends BaseOperator { // by searching backward for a whitespace character (space or tab). let breakpoint = Math.max( trimmedLine.lastIndexOf(' ', remaining), - trimmedLine.lastIndexOf('\t', remaining) + trimmedLine.lastIndexOf('\t', remaining), ); if (breakpoint < 0) { // Next word is too long to fit on the current line. diff --git a/src/actions/plugins/camelCaseMotion.ts b/src/actions/plugins/camelCaseMotion.ts index 8625307d8..f4e93e46a 100644 --- a/src/actions/plugins/camelCaseMotion.ts +++ b/src/actions/plugins/camelCaseMotion.ts @@ -59,7 +59,7 @@ class MoveCamelCaseWordEnd extends CamelCaseBaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const end = position.nextWordEnd(vimState.document, { wordType: WordType.CamelCase }); diff --git a/src/actions/plugins/easymotion/easymotion.cmd.ts b/src/actions/plugins/easymotion/easymotion.cmd.ts index bde65d34a..4da98a799 100644 --- a/src/actions/plugins/easymotion/easymotion.cmd.ts +++ b/src/actions/plugins/easymotion/easymotion.cmd.ts @@ -103,7 +103,7 @@ function getMatchesForString( position: Position, vimState: VimState, searchString: string, - options?: SearchOptions + options?: SearchOptions, ): Match[] { switch (searchString) { case '': @@ -114,7 +114,7 @@ function getMatchesForString( vimState.document, position, new RegExp(' {1,}', 'g'), - options + options, ); default: // Search all occurences of the character pressed @@ -131,7 +131,7 @@ function getMatchesForString( vimState.document, position, new RegExp(searchString, regexFlags), - options + options, ); } } @@ -197,7 +197,7 @@ export class SearchByNCharCommand extends BaseEasyMotionCommand implements EasyM position, vimState, this.removeTrailingLineBreak(this.searchString), - {} + {}, ); } @@ -264,7 +264,7 @@ export abstract class EasyMotionWordMoveCommandBase extends BaseEasyMotionComman private getMatchesForWord( position: Position, vimState: VimState, - options?: SearchOptions + options?: SearchOptions, ): Match[] { const regex = this._options.jumpToAnywhere ? new RegExp(configuration.easymotionJumpToAnywhereRegex, 'g') @@ -292,19 +292,19 @@ export abstract class EasyMotionLineMoveCommandBase extends BaseEasyMotionComman private getMatchesForLineStart( position: Position, vimState: VimState, - options?: SearchOptions + options?: SearchOptions, ): Match[] { // Search for the beginning of all non whitespace chars on each line before the cursor const matches = vimState.easyMotion.sortedSearch( vimState.document, position, new RegExp('^.', 'gm'), - options + options, ); for (const match of matches) { match.position = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - match.position.line + match.position.line, ); } return matches; diff --git a/src/actions/plugins/easymotion/easymotion.ts b/src/actions/plugins/easymotion/easymotion.ts index 1d7e2a655..202b61066 100644 --- a/src/actions/plugins/easymotion/easymotion.ts +++ b/src/actions/plugins/easymotion/easymotion.ts @@ -57,7 +57,7 @@ export class EasyMotion implements IEasyMotion { */ public static getDecorationType( length: number, - decorations?: vscode.DecorationRenderOptions + decorations?: vscode.DecorationRenderOptions, ): vscode.TextEditorDecorationType { const cache = this.decorationTypeCache[length]; if (cache) { @@ -112,7 +112,7 @@ export class EasyMotion implements IEasyMotion { document: vscode.TextDocument, position: Position, search: string | RegExp = '', - options: SearchOptions = {} + options: SearchOptions = {}, ): Match[] { const regex = typeof search === 'string' @@ -184,7 +184,7 @@ export class EasyMotion implements IEasyMotion { private getMarkerColor( customizedValue: string, - themeColorId: string + themeColorId: string, ): string | vscode.ThemeColor { if (customizedValue) { return customizedValue; @@ -206,14 +206,14 @@ export class EasyMotion implements IEasyMotion { private getEasymotionMarkerForegroundColorTwoCharFirst() { return this.getMarkerColor( configuration.easymotionMarkerForegroundColorTwoCharFirst, - '#ffb400' + '#ffb400', ); } private getEasymotionMarkerForegroundColorTwoCharSecond() { return this.getMarkerColor( configuration.easymotionMarkerForegroundColorTwoCharSecond, - '#b98300' + '#b98300', ); } @@ -319,7 +319,7 @@ export class EasyMotion implements IEasyMotion { pos.line, pos.character + 1, pos.line, - pos.character + 1 + pos.character + 1, ); const secondCharRenderOptions: vscode.ThemableDecorationInstanceRenderOptions = { @@ -343,7 +343,12 @@ export class EasyMotion implements IEasyMotion { } hiddenChars.push( - new vscode.Range(pos.line, pos.character, pos.line, pos.character + keystroke.length + trim) + new vscode.Range( + pos.line, + pos.character, + pos.line, + pos.character + keystroke.length + trim, + ), ); if (configuration.easymotionDimBackground) { @@ -363,7 +368,7 @@ export class EasyMotion implements IEasyMotion { const prevKeystroke = prevMarker.name.substring(this.accumulation.length); const prevDimPos = prevMarker.position; const offsetPrevDimPos = prevDimPos.withColumn( - prevDimPos.character + prevKeystroke.length + prevDimPos.character + prevKeystroke.length, ); // Don't create dimming ranges in between consecutive markers (the 'after' is in the cases @@ -377,7 +382,7 @@ export class EasyMotion implements IEasyMotion { offsetPrevDimPos.line, offsetPrevDimPos.character, pos.line, - pos.character + pos.character, ), renderOptions: dimmingRenderOptions, }); @@ -400,7 +405,7 @@ export class EasyMotion implements IEasyMotion { dimmingZones.push({ range: new vscode.Range( offsetPrevDimPos, - new Position(editor.document.lineCount, Number.MAX_VALUE) + new Position(editor.document.lineCount, Number.MAX_VALUE), ), renderOptions: dimmingRenderOptions, }); diff --git a/src/actions/plugins/easymotion/types.ts b/src/actions/plugins/easymotion/types.ts index 2a343e4e6..b9918dd1a 100644 --- a/src/actions/plugins/easymotion/types.ts +++ b/src/actions/plugins/easymotion/types.ts @@ -81,7 +81,7 @@ export interface IEasyMotion { document: vscode.TextDocument, position: Position, search?: string | RegExp, - options?: SearchOptions + options?: SearchOptions, ): Match[]; updateDecorations(editor: vscode.TextEditor): void; clearMarkers(): void; diff --git a/src/actions/plugins/replaceWithRegister.ts b/src/actions/plugins/replaceWithRegister.ts index 3793b4d8f..8aad7d811 100644 --- a/src/actions/plugins/replaceWithRegister.ts +++ b/src/actions/plugins/replaceWithRegister.ts @@ -32,7 +32,7 @@ class ReplaceOperator extends BaseOperator { if (register === undefined) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName) + VimError.fromCode(ErrorCode.NothingInRegister, vimState.recordedState.registerName), ); return; } diff --git a/src/actions/plugins/sneak.ts b/src/actions/plugins/sneak.ts index 17ee52f6a..946af8943 100644 --- a/src/actions/plugins/sneak.ts +++ b/src/actions/plugins/sneak.ts @@ -24,7 +24,7 @@ export class SneakForward extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { if (!this.isRepeat) { vimState.lastSemicolonRepeatableMovement = new SneakForward(this.keysPressed, true); @@ -91,7 +91,7 @@ export class SneakBackward extends BaseMovement { public override async execAction( position: Position, - vimState: VimState + vimState: VimState, ): Promise { if (!this.isRepeat) { vimState.lastSemicolonRepeatableMovement = new SneakBackward(this.keysPressed, true); diff --git a/src/actions/plugins/surround.ts b/src/actions/plugins/surround.ts index 558130e51..defec7e11 100644 --- a/src/actions/plugins/surround.ts +++ b/src/actions/plugins/surround.ts @@ -126,7 +126,7 @@ class YankSurroundOperator extends SurroundOperator { public override async runRepeat( vimState: VimState, position: Position, - count: number + count: number, ): Promise { // we want to act on range: first non whitespace to last non whitespace await this.run( @@ -135,7 +135,7 @@ class YankSurroundOperator extends SurroundOperator { position .getDown(Math.max(0, count - 1)) .getLineEnd() - .prevWordEnd(vimState.document) + .prevWordEnd(vimState.document), ); } } @@ -228,7 +228,7 @@ class CommandSurroundDeleteSurround extends CommandSurround { const replaceRanges = await SurroundHelper.getReplaceRanges( vimState, position, - this.multicursorIndex ?? 0 + this.multicursorIndex ?? 0, ); if (replaceRanges) { @@ -274,7 +274,7 @@ class CommandSurroundChangeSurround extends CommandSurround { const replaceRanges = await SurroundHelper.getReplaceRanges( vimState, position, - this.multicursorIndex ?? 0 + this.multicursorIndex ?? 0, ); // collect ranges for all cursors @@ -520,7 +520,7 @@ class SurroundHelper { public static async getReplaceRanges( vimState: VimState, position: Position, - multicursorIndex: number + multicursorIndex: number, ): Promise { /* so this method is a bit of a dumpster for edge cases and ugly details the main idea is this: @@ -578,7 +578,7 @@ class SurroundHelper { function checkRemoveSpace(): number { // capiche? const leftSpace = vimState.editor.document.getText( - new Range(rangeStart.getRight(), rangeStart.getRight(2)) + new Range(rangeStart.getRight(), rangeStart.getRight(2)), ); const rightSpace = vimState.editor.document.getText(new Range(rangeEnd.getLeft(), rangeEnd)); return removeSpace && leftSpace === ' ' && rightSpace === ' ' ? 1 : 0; diff --git a/src/actions/plugins/targets/lastNextObjectHelper.ts b/src/actions/plugins/targets/lastNextObjectHelper.ts index d74e0f3fe..773a179e3 100644 --- a/src/actions/plugins/targets/lastNextObjectHelper.ts +++ b/src/actions/plugins/targets/lastNextObjectHelper.ts @@ -81,7 +81,7 @@ function LastNextObject(type: new () => T, which: position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { const maybePosition = searchPosition(this.charToFind, vimState.document, position, { direction: which === 'l' ? '<' : '>', @@ -97,7 +97,7 @@ function LastNextObject(type: new () => T, which: maybePosition, vimState, firstIteration, - lastIteration + lastIteration, ); if (movement.failed) { return movement; diff --git a/src/actions/plugins/targets/searchUtils.ts b/src/actions/plugins/targets/searchUtils.ts index 693f371db..c81f73547 100644 --- a/src/actions/plugins/targets/searchUtils.ts +++ b/src/actions/plugins/targets/searchUtils.ts @@ -14,7 +14,7 @@ function searchForward( throughLineBreaks?: boolean; } = { throughLineBreaks: false, - } + }, ): Position | undefined { let position = start; for ( @@ -41,7 +41,7 @@ function searchBackward( throughLineBreaks?: boolean; } = { throughLineBreaks: false, - } + }, ): Position | undefined { let position = start; for ( @@ -66,7 +66,7 @@ export function maybeGetLeft( count = 1, throughLineBreaks, dontMove, - }: { count?: number; throughLineBreaks?: boolean; dontMove?: boolean } + }: { count?: number; throughLineBreaks?: boolean; dontMove?: boolean }, ) { return dontMove ? position @@ -80,7 +80,7 @@ export function maybeGetRight( count = 1, throughLineBreaks, dontMove, - }: { count?: number; throughLineBreaks?: boolean; dontMove?: boolean } + }: { count?: number; throughLineBreaks?: boolean; dontMove?: boolean }, ) { return dontMove ? position @@ -97,7 +97,7 @@ export function searchPosition( direction: '>', includeCursor: true, throughLineBreaks: false, - } + }, ): Position | undefined { if (flags.direction === '<') { start = maybeGetLeft(start, { diff --git a/src/actions/plugins/targets/smartQuotesMatcher.ts b/src/actions/plugins/targets/smartQuotesMatcher.ts index a6d49fc33..271dba16d 100644 --- a/src/actions/plugins/targets/smartQuotesMatcher.ts +++ b/src/actions/plugins/targets/smartQuotesMatcher.ts @@ -200,7 +200,7 @@ export class SmartQuoteMatcher { public smartSurroundingQuotes( position: Position, - which: WhichQuotes + which: WhichQuotes, ): { start: Position; stop: Position; lineText: string } | undefined { position = this.document.validatePosition(position); const cursorIndex = position.character; @@ -276,7 +276,7 @@ export class SmartQuoteMatcher { private smartSearch( start: number, action: SearchAction, - quoteMap: QuoteMatch[] + quoteMap: QuoteMatch[], ): [number, number] | undefined { const offset = action.includeCurrent ? 1 : 0; let cursorPos: number | undefined = start; diff --git a/src/cmd_line/commandLine.ts b/src/cmd_line/commandLine.ts index c3ef14ae1..cf826d848 100644 --- a/src/cmd_line/commandLine.ts +++ b/src/cmd_line/commandLine.ts @@ -217,8 +217,8 @@ export class ExCommandLine extends CommandLine { public display(cursorChar: string): string { return escapeCSSIcons( `:${this.text.substring(0, this.cursorIndex)}${cursorChar}${this.text.substring( - this.cursorIndex - )}` + this.cursorIndex, + )}`, ); } @@ -353,8 +353,8 @@ export class SearchCommandLine extends CommandLine { .get() .forEach((val) => SearchCommandLine.previousSearchStates.push( - new SearchState(SearchDirection.Forward, new Position(0, 0), val, undefined) - ) + new SearchState(SearchDirection.Forward, new Position(0, 0), val, undefined), + ), ); } @@ -397,8 +397,8 @@ export class SearchCommandLine extends CommandLine { return escapeCSSIcons( `${this.searchState.direction === SearchDirection.Forward ? '/' : '?'}${this.text.substring( 0, - this.cursorIndex - )}${cursorChar}${this.text.substring(this.cursorIndex)}` + this.cursorIndex, + )}${cursorChar}${this.text.substring(this.cursorIndex)}`, ); } @@ -436,7 +436,7 @@ export class SearchCommandLine extends CommandLine { vimState, vimState.cursorStopPosition, SearchDirection.Forward, - this.getCurrentMatchRelativeIndex(vimState) + this.getCurrentMatchRelativeIndex(vimState), ); } @@ -450,7 +450,7 @@ export class SearchCommandLine extends CommandLine { vimState, vimState.cursorStopPosition, SearchDirection.Forward, - this.getCurrentMatchRelativeIndex(vimState) + this.getCurrentMatchRelativeIndex(vimState), ); } @@ -459,7 +459,7 @@ export class SearchCommandLine extends CommandLine { this.searchState.getMatchRanges(vimState), configuration.incsearch && vimState.currentMode === Mode.SearchInProgressMode ? this.getCurrentMatchRange(vimState)?.index - : undefined + : undefined, ); } @@ -494,8 +494,8 @@ export class SearchCommandLine extends CommandLine { this.searchState.direction === SearchDirection.Backward ? ErrorCode.SearchHitTop : ErrorCode.SearchHitBottom, - this.text - ) + this.text, + ), ); return; } diff --git a/src/cmd_line/commands/bang.ts b/src/cmd_line/commands/bang.ts index 05d927e9c..6b3f082c4 100644 --- a/src/cmd_line/commands/bang.ts +++ b/src/cmd_line/commands/bang.ts @@ -14,7 +14,7 @@ export class BangCommand extends ExCommand { (command) => new BangCommand({ command, - }) + }), ); protected _arguments: IBangCommandArguments; diff --git a/src/cmd_line/commands/breakpoints.ts b/src/cmd_line/commands/breakpoints.ts index 64bc460c4..3a1965897 100644 --- a/src/cmd_line/commands/breakpoints.ts +++ b/src/cmd_line/commands/breakpoints.ts @@ -59,7 +59,7 @@ class AddBreakpointCommand extends ExCommand { } const location = new vscode.Location( file, - new vscode.Position(this.addBreakpoint.line - 1, 0) + new vscode.Position(this.addBreakpoint.line - 1, 0), ); return vscode.debug.addBreakpoints([new vscode.SourceBreakpoint(location)]); } else if (this.addBreakpoint.type === 'func') { @@ -102,7 +102,7 @@ class DeleteBreakpointCommand extends ExCommand { async execute(vimState: VimState): Promise { if (this.delBreakpoint.type === 'byId') { return vscode.debug.removeBreakpoints( - vscode.debug.breakpoints.slice(this.delBreakpoint.id - 1, 1) + vscode.debug.breakpoints.slice(this.delBreakpoint.id - 1, 1), ); } else if (this.delBreakpoint.type === 'all') { return vscode.debug.removeBreakpoints(vscode.debug.breakpoints); @@ -121,7 +121,7 @@ class DeleteBreakpointCommand extends ExCommand { .find( (b) => b.location.uri.toString() === reqUri.toString() && - b.location.range.start.line === reqLine + b.location.range.start.line === reqLine, ); if (breakpoint) return vscode.debug.removeBreakpoints([breakpoint]); } else if (this.delBreakpoint.type === 'func') { @@ -140,7 +140,7 @@ class DeleteBreakpointCommand extends ExCommand { .filter( (b) => b.location.uri.toString() === location.uri.toString() && - b.location.range.start.line === location.range.start.line + b.location.range.start.line === location.range.start.line, ) .sort((a, b) => distFromLocationCharacter(a) - distFromLocationCharacter(b))[0]; if (breakpoint) return vscode.debug.removeBreakpoints([breakpoint]); @@ -196,21 +196,21 @@ export class Breakpoints { seqObj( ['type', string('file')], ['line', optWhitespace.then(numberParser).fallback(1)], - ['file', optWhitespace.then(fileNameParser).fallback('')] + ['file', optWhitespace.then(fileNameParser).fallback('')], ), // func seqObj( ['type', string('func')], optWhitespace.then(numberParser).fallback(1), // we don't support line numbers in function names, but Vim does, so we'll allow it. - ['function', optWhitespace.then(regexp(/\S+/))] + ['function', optWhitespace.then(regexp(/\S+/))], ), // expr - seqObj(['type', string('expr')], ['expr', optWhitespace.then(all)]) - ) + seqObj(['type', string('expr')], ['expr', optWhitespace.then(all)]), + ), ) .or( // without arg - eof.result({ type: 'here' }) + eof.result({ type: 'here' }), ) .map((a) => new AddBreakpointCommand(a)), @@ -223,23 +223,23 @@ export class Breakpoints { seqObj( ['type', string('file')], ['line', optWhitespace.then(numberParser).fallback(1)], - ['file', optWhitespace.then(fileNameParser).fallback('')] + ['file', optWhitespace.then(fileNameParser).fallback('')], ), // func seqObj( ['type', string('func')], optWhitespace.then(numberParser).fallback(1), // we don't support line numbers in function names, but Vim does, so we'll allow it. - ['function', optWhitespace.then(regexp(/\S+/))] + ['function', optWhitespace.then(regexp(/\S+/))], ), // all string('*').then(optWhitespace).result({ type: 'all' }), // by number - numberParser.map((n) => ({ type: 'byId', id: n })) - ) + numberParser.map((n) => ({ type: 'byId', id: n })), + ), ) .or( // without arg - eof.result({ type: 'here' }) + eof.result({ type: 'here' }), ) .map((a) => new DeleteBreakpointCommand(a)), diff --git a/src/cmd_line/commands/bufferDelete.ts b/src/cmd_line/commands/bufferDelete.ts index c61812bd0..bcc41f088 100644 --- a/src/cmd_line/commands/bufferDelete.ts +++ b/src/cmd_line/commands/bufferDelete.ts @@ -19,7 +19,7 @@ interface IBufferDeleteCommandArguments { export class BufferDeleteCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser.skip(optWhitespace), - alt(numberParser, fileNameParser).sepBy(whitespace) + alt(numberParser, fileNameParser).sepBy(whitespace), ).map(([bang, buffers]) => new BufferDeleteCommand({ bang, buffers })); public readonly arguments: IBufferDeleteCommandArguments; @@ -42,7 +42,7 @@ export class BufferDeleteCommand extends ExCommand { StatusBar.setText( vimState, ':bd[elete][!] {bufname} is not yet implemented (PRs are welcome!)', - true + true, ); continue; } diff --git a/src/cmd_line/commands/close.ts b/src/cmd_line/commands/close.ts index efdfd3286..f7c120075 100644 --- a/src/cmd_line/commands/close.ts +++ b/src/cmd_line/commands/close.ts @@ -12,7 +12,7 @@ import { bangParser } from '../../vimscript/parserUtils'; // export class CloseCommand extends ExCommand { public static readonly argParser: Parser = bangParser.map( - (bang) => new CloseCommand(bang) + (bang) => new CloseCommand(bang), ); public readonly bang: boolean; diff --git a/src/cmd_line/commands/copy.ts b/src/cmd_line/commands/copy.ts index cb41d4b26..0b0e81688 100644 --- a/src/cmd_line/commands/copy.ts +++ b/src/cmd_line/commands/copy.ts @@ -34,7 +34,7 @@ export class CopyCommand extends ExCommand { } const copiedText = vimState.document.getText( - new Range(new Position(sourceStart, 0), new Position(sourceEnd, 0).getLineEnd()) + new Range(new Position(sourceStart, 0), new Position(sourceEnd, 0).getLineEnd()), ); let text: string; @@ -50,13 +50,13 @@ export class CopyCommand extends ExCommand { const lines = copiedText.split('\n'); const cursorPosition = new Position( Math.max(dest + lines.length, 0), - lines[lines.length - 1].match(/\S/)?.index ?? 0 + lines[lines.length - 1].match(/\S/)?.index ?? 0, ); vimState.recordedState.transformer.insert( position, text, - PositionDiff.exactPosition(cursorPosition) + PositionDiff.exactPosition(cursorPosition), ); } diff --git a/src/cmd_line/commands/delete.ts b/src/cmd_line/commands/delete.ts index a9fa8215d..aa9ccba0d 100644 --- a/src/cmd_line/commands/delete.ts +++ b/src/cmd_line/commands/delete.ts @@ -23,15 +23,15 @@ export class DeleteCommand extends ExCommand { seq(any.fallback(undefined), whitespace.then(numberParser).fallback(undefined)).map( ([register, count]) => { return { register, count }; - } - ) + }, + ), ).map( ({ register, count }) => new DeleteCommand({ register, count, - }) - ) + }), + ), ); private readonly arguments: IDeleteCommandArguments; diff --git a/src/cmd_line/commands/digraph.ts b/src/cmd_line/commands/digraph.ts index 304e8ff60..0d95db563 100644 --- a/src/cmd_line/commands/digraph.ts +++ b/src/cmd_line/commands/digraph.ts @@ -21,7 +21,7 @@ interface DigraphQuickPickItem extends vscode.QuickPickItem { export class DigraphsCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser, - whitespace.then(seq(any, any, whitespace.then(numberParser))).many() + whitespace.then(seq(any, any, whitespace.then(numberParser))).many(), ).map(([bang, newDigraphs]) => new DigraphsCommand({ bang, newDigraphs })); private readonly arguments: IDigraphsCommandArguments; @@ -47,7 +47,7 @@ export class DigraphsCommand extends ExCommand { // TODO: use arguments const digraphKeyAndContent = this.makeQuickPicks(Object.entries(configuration.digraphs)).concat( - this.makeQuickPicks([...DefaultDigraphs.entries()]) + this.makeQuickPicks([...DefaultDigraphs.entries()]), ); vscode.window.showQuickPick(digraphKeyAndContent).then(async (val) => { diff --git a/src/cmd_line/commands/file.ts b/src/cmd_line/commands/file.ts index e193413e7..c629a4c2b 100644 --- a/src/cmd_line/commands/file.ts +++ b/src/cmd_line/commands/file.ts @@ -84,28 +84,28 @@ export class FileCommand extends ExCommand { bangParser, optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(fileNameParser).fallback(undefined) + optWhitespace.then(fileNameParser).fallback(undefined), ).map(([bang, opt, cmd, file]) => new FileCommand({ name: 'edit', bang, opt, cmd, file })), enew: bangParser.map((bang) => new FileCommand({ name: 'enew', bang })), new: seq( optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(fileNameParser).fallback(undefined) + optWhitespace.then(fileNameParser).fallback(undefined), ).map(([opt, cmd, file]) => new FileCommand({ name: 'new', opt, cmd, file })), split: seq( optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(fileNameParser).fallback(undefined) + optWhitespace.then(fileNameParser).fallback(undefined), ).map(([opt, cmd, file]) => new FileCommand({ name: 'split', opt, cmd, file })), vnew: seq( optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(fileNameParser).fallback(undefined) + optWhitespace.then(fileNameParser).fallback(undefined), ).map(([opt, cmd, file]) => new FileCommand({ name: 'vnew', opt, cmd, file })), vsplit: seq( optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(fileNameParser).fallback(undefined) + optWhitespace.then(fileNameParser).fallback(undefined), ).map(([opt, cmd, file]) => new FileCommand({ name: 'vsplit', opt, cmd, file })), }; @@ -231,7 +231,7 @@ export class FileCommand extends ExCommand { : undefined; if (lineNumber !== undefined && lineNumber >= 0) { vscode.window.activeTextEditor!.revealRange( - new vscode.Range(new vscode.Position(lineNumber, 0), new vscode.Position(lineNumber, 0)) + new vscode.Range(new vscode.Position(lineNumber, 0), new vscode.Position(lineNumber, 0)), ); } await hidePreviousEditor(); diff --git a/src/cmd_line/commands/fileInfo.ts b/src/cmd_line/commands/fileInfo.ts index 3180cc4e0..e08b9dbcb 100644 --- a/src/cmd_line/commands/fileInfo.ts +++ b/src/cmd_line/commands/fileInfo.ts @@ -7,7 +7,7 @@ import { bangParser } from '../../vimscript/parserUtils'; export class FileInfoCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser, - optWhitespace.then(all) + optWhitespace.then(all), ).map(([bang, fileName]) => new FileInfoCommand({ bang, fileName })); private args: { diff --git a/src/cmd_line/commands/history.ts b/src/cmd_line/commands/history.ts index b92dfb372..66e4e40da 100644 --- a/src/cmd_line/commands/history.ts +++ b/src/cmd_line/commands/history.ts @@ -23,7 +23,7 @@ const historyTypeParser: Parser = alt( alt(nameAbbrevParser('e', 'xpr'), string('=')).result(HistoryCommandType.Expr), alt(nameAbbrevParser('i', 'nput'), string('@')).result(HistoryCommandType.Input), alt(nameAbbrevParser('d', 'ebug'), string('>')).result(HistoryCommandType.Debug), - nameAbbrevParser('a', 'll').result(HistoryCommandType.All) + nameAbbrevParser('a', 'll').result(HistoryCommandType.All), ); export interface IHistoryCommandArguments { @@ -51,7 +51,7 @@ export class HistoryCommand extends ExCommand { case HistoryCommandType.Search: await new CommandShowSearchHistory(SearchDirection.Forward).exec( vimState.cursorStopPosition, - vimState + vimState, ); break; // TODO: Implement these diff --git a/src/cmd_line/commands/leftRightCenter.ts b/src/cmd_line/commands/leftRightCenter.ts index ec4ee1eb6..8be8d559a 100644 --- a/src/cmd_line/commands/leftRightCenter.ts +++ b/src/cmd_line/commands/leftRightCenter.ts @@ -38,9 +38,9 @@ export class LeftCommand extends ExCommand { lines .map( (line) => - ' '.repeat(this.args.indent) + line.text.slice(line.firstNonWhitespaceCharacterIndex) + ' '.repeat(this.args.indent) + line.text.slice(line.firstNonWhitespaceCharacterIndex), ) - .join('\n') + .join('\n'), ); } } @@ -79,12 +79,12 @@ export class RightCommand extends ExCommand { const indent = ' '.repeat( Math.max( 0, - this.args.width - (line.text.length - line.firstNonWhitespaceCharacterIndex) - ) + this.args.width - (line.text.length - line.firstNonWhitespaceCharacterIndex), + ), ); return indent + line.text.slice(line.firstNonWhitespaceCharacterIndex); }) - .join('\n') + .join('\n'), ); } } @@ -123,12 +123,12 @@ export class CenterCommand extends ExCommand { const indent = ' '.repeat( Math.max( 0, - this.args.width - (line.text.length - line.firstNonWhitespaceCharacterIndex) - ) / 2 + this.args.width - (line.text.length - line.firstNonWhitespaceCharacterIndex), + ) / 2, ); return indent + line.text.slice(line.firstNonWhitespaceCharacterIndex); }) - .join('\n') + .join('\n'), ); } } diff --git a/src/cmd_line/commands/marks.ts b/src/cmd_line/commands/marks.ts index f949cb487..1f79b9f4d 100644 --- a/src/cmd_line/commands/marks.ts +++ b/src/cmd_line/commands/marks.ts @@ -79,11 +79,11 @@ export class DeleteMarksCommand extends ExCommand { seq(regexp(/[0-9]/).skip(string('-')), regexp(/[0-9]/)).map(([start, end]) => { return { start, end }; }), - noneOf('-') - ) + noneOf('-'), + ), ) - .many() - ) + .many(), + ), ).map((marks) => new DeleteMarksCommand(marks)); private args: DeleteMarksArgs; diff --git a/src/cmd_line/commands/move.ts b/src/cmd_line/commands/move.ts index cd23f600a..8001ee85b 100644 --- a/src/cmd_line/commands/move.ts +++ b/src/cmd_line/commands/move.ts @@ -43,7 +43,7 @@ export class MoveCommand extends ExCommand { // copy const copiedText = vimState.document.getText( - new Range(new Position(sourceStart, 0), new Position(sourceEnd, 0).getLineEnd()) + new Range(new Position(sourceStart, 0), new Position(sourceEnd, 0).getLineEnd()), ); let text: string; @@ -62,12 +62,12 @@ export class MoveCommand extends ExCommand { // make the cursor position at the beginning of the endline. cursorPosition = new Position( Math.max(dest, 0), - lines[lines.length - 1].match(/\S/)?.index ?? 0 + lines[lines.length - 1].match(/\S/)?.index ?? 0, ); } else { cursorPosition = new Position( Math.max(dest + lines.length, 0), - lines[lines.length - 1].match(/\S/)?.index ?? 0 + lines[lines.length - 1].match(/\S/)?.index ?? 0, ); } // delete @@ -89,7 +89,7 @@ export class MoveCommand extends ExCommand { vimState.recordedState.transformer.insert( position, text, - PositionDiff.exactPosition(cursorPosition) + PositionDiff.exactPosition(cursorPosition), ); } diff --git a/src/cmd_line/commands/put.ts b/src/cmd_line/commands/put.ts index 5c22fd7a7..5d9fd4dbf 100644 --- a/src/cmd_line/commands/put.ts +++ b/src/cmd_line/commands/put.ts @@ -31,8 +31,8 @@ export class PutExCommand extends ExCommand { optWhitespace .then(any) .map((x) => ({ register: x })) - .fallback({ register: undefined }) - ) + .fallback({ register: undefined }), + ), ).map(([bang, register]) => new PutExCommand({ bang, ...register })); public readonly arguments: IPutCommandArguments; @@ -53,7 +53,7 @@ export class PutExCommand extends ExCommand { vimState, this.arguments.register, this.arguments.fromExpression, - 0 + 0, ); } diff --git a/src/cmd_line/commands/quit.ts b/src/cmd_line/commands/quit.ts index 8bab79c03..6ccf86add 100644 --- a/src/cmd_line/commands/quit.ts +++ b/src/cmd_line/commands/quit.ts @@ -17,14 +17,14 @@ export interface IQuitCommandArguments { // export class QuitCommand extends ExCommand { public static readonly argParser: (quitAll: boolean) => Parser = ( - quitAll: boolean + quitAll: boolean, ) => bangParser.map( (bang) => new QuitCommand({ bang, quitAll, - }) + }), ); public override isRepeatableWithDot = false; diff --git a/src/cmd_line/commands/read.ts b/src/cmd_line/commands/read.ts index ce71ed7a7..c71fd7ca3 100644 --- a/src/cmd_line/commands/read.ts +++ b/src/cmd_line/commands/read.ts @@ -5,10 +5,9 @@ import { ExCommand } from '../../vimscript/exCommand'; import { fileNameParser, FileOpt, fileOptParser } from '../../vimscript/parserUtils'; import { all, alt, optWhitespace, Parser, seq, string, whitespace } from 'parsimmon'; -export type IReadCommandArguments = - | { - opt: FileOpt; - } & ({ cmd: string } | { file: string } | {}); +export type IReadCommandArguments = { + opt: FileOpt; +} & ({ cmd: string } | { file: string } | {}); // // Implements :read and :read! @@ -28,10 +27,10 @@ export class ReadCommand extends ExCommand { }), fileNameParser.map((file) => { return { file }; - }) - ) + }), + ), ) - .fallback(undefined) + .fallback(undefined), ).map(([opt, other]) => new ReadCommand({ opt, ...other })); private readonly arguments: IReadCommandArguments; @@ -49,7 +48,7 @@ export class ReadCommand extends ExCommand { if (textToInsert) { vimState.recordedState.transformer.insert( vimState.cursorStopPosition.getLineEnd(), - '\n' + textToInsert + '\n' + textToInsert, ); } } diff --git a/src/cmd_line/commands/register.ts b/src/cmd_line/commands/register.ts index bd7218d8e..c90f6ad85 100644 --- a/src/cmd_line/commands/register.ts +++ b/src/cmd_line/commands/register.ts @@ -10,7 +10,7 @@ import { any, optWhitespace, Parser } from 'parsimmon'; export class RegisterCommand extends ExCommand { public static readonly argParser: Parser = optWhitespace.then( - any.sepBy(optWhitespace).map((registers) => new RegisterCommand(registers)) + any.sepBy(optWhitespace).map((registers) => new RegisterCommand(registers)), ); private readonly registers: string[]; @@ -61,7 +61,7 @@ export class RegisterCommand extends ExCommand { } else { const currentRegisterKeys = Register.getKeys() .filter( - (reg) => reg !== '_' && (this.registers.length === 0 || this.registers.includes(reg)) + (reg) => reg !== '_' && (this.registers.length === 0 || this.registers.includes(reg)), ) .sort((reg1: string, reg2: string) => this.regSortOrder(reg1) - this.regSortOrder(reg2)); const registerKeyAndContent = new Array(); diff --git a/src/cmd_line/commands/retab.ts b/src/cmd_line/commands/retab.ts index b7acd3832..5ca0832e5 100644 --- a/src/cmd_line/commands/retab.ts +++ b/src/cmd_line/commands/retab.ts @@ -22,13 +22,13 @@ interface UpdatedLineSegment { export class RetabCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser, - optWhitespace.then(numberParser).fallback(undefined) + optWhitespace.then(numberParser).fallback(undefined), ).map( ([replaceSpaces, newTabstop]) => new RetabCommand({ replaceSpaces, newTabstop, - }) + }), ); private readonly arguments: IRetabCommandArguments; @@ -88,7 +88,7 @@ export class RetabCommand extends ExCommand { retabLineSegment( segment: string, start: number, - tabstop = configuration.tabstop + tabstop = configuration.tabstop, ): UpdatedLineSegment { const retab = this.arguments.replaceSpaces || this.hasTabs(segment); diff --git a/src/cmd_line/commands/set.ts b/src/cmd_line/commands/set.ts index 5a02c2544..37c861924 100644 --- a/src/cmd_line/commands/set.ts +++ b/src/cmd_line/commands/set.ts @@ -102,7 +102,7 @@ const setOperationParser: Parser = whitespace option, source, }; - } + }, ), seq(optionParser.skip(oneOf('=:')), valueParser).map(([option, value]) => { return { @@ -137,14 +137,14 @@ const setOperationParser: Parser = whitespace type: 'show_or_set', option, }; - }) - ) + }), + ), ) .fallback({ type: 'show_or_set', option: undefined }); export class SetCommand extends ExCommand { public static readonly argParser: Parser = setOperationParser.map( - (operation) => new SetCommand(operation) + (operation) => new SetCommand(operation), ); private readonly operation: SetOperation; @@ -225,7 +225,7 @@ export class SetCommand extends ExCommand { // TODO: Could also be {option}:{value} throw VimError.fromCode( ErrorCode.NumberRequiredAfterEqual, - `${option}=${this.operation.value}` + `${option}=${this.operation.value}`, ); } configuration[option] = value; @@ -242,7 +242,7 @@ export class SetCommand extends ExCommand { if (isNaN(value)) { throw VimError.fromCode( ErrorCode.NumberRequiredAfterEqual, - `${option}+=${this.operation.value}` + `${option}+=${this.operation.value}`, ); } configuration[option] = currentValue + value; @@ -259,7 +259,7 @@ export class SetCommand extends ExCommand { if (isNaN(value)) { throw VimError.fromCode( ErrorCode.NumberRequiredAfterEqual, - `${option}^=${this.operation.value}` + `${option}^=${this.operation.value}`, ); } configuration[option] = currentValue * value; @@ -276,7 +276,7 @@ export class SetCommand extends ExCommand { if (isNaN(value)) { throw VimError.fromCode( ErrorCode.NumberRequiredAfterEqual, - `${option}-=${this.operation.value}` + `${option}-=${this.operation.value}`, ); } configuration[option] = currentValue - value; diff --git a/src/cmd_line/commands/shift.ts b/src/cmd_line/commands/shift.ts index 64830297b..0d1f8ba13 100644 --- a/src/cmd_line/commands/shift.ts +++ b/src/cmd_line/commands/shift.ts @@ -25,8 +25,8 @@ export class ShiftCommand extends ExCommand { .map((shifts) => shifts.length + 1) .skip(optWhitespace), // `:> 2` indents 2 lines - numberParser.fallback(undefined) - ) + numberParser.fallback(undefined), + ), ) .map(([depth, numLines]) => new ShiftCommand({ dir, depth, numLines })); diff --git a/src/cmd_line/commands/sort.ts b/src/cmd_line/commands/sort.ts index 59a462415..b1a464c02 100644 --- a/src/cmd_line/commands/sort.ts +++ b/src/cmd_line/commands/sort.ts @@ -21,7 +21,7 @@ export interface ISortCommandArguments { export class SortCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser, - optWhitespace.then(oneOf('bfilnorux').many()) + optWhitespace.then(oneOf('bfilnorux').many()), ).map( ([bang, flags]) => new SortCommand({ @@ -29,7 +29,7 @@ export class SortCommand extends ExCommand { ignoreCase: flags.includes('i'), unique: flags.includes('u'), numeric: flags.includes('n'), - }) + }), ); private readonly arguments: ISortCommandArguments; @@ -82,7 +82,7 @@ export class SortCommand extends ExCommand { sortedLines = originalLines.sort( (a: string, b: string) => (NumericString.parse(a, NumericStringRadix.Dec)?.num.value ?? Number.MAX_VALUE) - - (NumericString.parse(b, NumericStringRadix.Dec)?.num.value ?? Number.MAX_VALUE) + (NumericString.parse(b, NumericStringRadix.Dec)?.num.value ?? Number.MAX_VALUE), ); } else if (this.arguments.ignoreCase) { sortedLines = originalLines.sort((a: string, b: string) => a.localeCompare(b)); @@ -101,7 +101,7 @@ export class SortCommand extends ExCommand { range: new vscode.Range(startLine, 0, endLine, lastLineLength), text: sortedContent, diff: PositionDiff.exactPosition( - new vscode.Position(startLine, sortedLines[0].match(/\S/)?.index ?? 0) + new vscode.Position(startLine, sortedLines[0].match(/\S/)?.index ?? 0), ), }); } diff --git a/src/cmd_line/commands/substitute.ts b/src/cmd_line/commands/substitute.ts index 6cbd3add5..864cca291 100644 --- a/src/cmd_line/commands/substitute.ts +++ b/src/cmd_line/commands/substitute.ts @@ -136,18 +136,18 @@ const replaceStringParser = (delimiter: string): Parser => } else { return { type: 'string' as const, value: `\\${escaped}` }; } - }) + }), ), string('&').result({ type: 'capture_group' as const, group: '&' }), string('~').result({ type: 'prev_replace_string' as const }), - noneOf(delimiter).map((value) => ({ type: 'string', value })) + noneOf(delimiter).map((value) => ({ type: 'string', value })), ) .many() .map((components) => new ReplaceString(components)); const substituteFlagsParser: Parser = seq( string('&').fallback(undefined), - oneOf('cegiInp#lr').many() + oneOf('cegiInp#lr').many(), ).map(([amp, flagChars]) => { const flags: SubstituteFlags = {}; if (amp === '&') { @@ -228,11 +228,11 @@ export class SubstituteCommand extends ExCommand { Pattern.parser({ direction: SearchDirection.Forward, delimiter }), replaceStringParser(delimiter), string(delimiter).then(substituteFlagsParser).fallback({}), - countParser + countParser, ).map( ([pattern, replace, flags, count]) => - new SubstituteCommand({ pattern, replace, flags, count }) - ) + new SubstituteCommand({ pattern, replace, flags, count }), + ), ), // :s[ubstitute] [flags] [count] @@ -243,9 +243,9 @@ export class SubstituteCommand extends ExCommand { replace: new ReplaceString([]), flags, count, - }) - ) - ) + }), + ), + ), ); public readonly arguments: ISubstituteCommandArguments; @@ -265,7 +265,7 @@ export class SubstituteCommand extends ExCommand { public getSubstitutionDecorations( vimState: VimState, - lineRange = new LineRange(new Address({ type: 'current_line' })) + lineRange = new LineRange(new Address({ type: 'current_line' })), ): SearchDecorations { const substitutionAppend: DecorationOptions[] = []; const substitutionReplace: DecorationOptions[] = []; @@ -298,7 +298,7 @@ export class SubstituteCommand extends ExCommand { if (showReplacements) { const contentText = formatDecorationText( replace.resolve(match.groups), - vimState.editor.options.tabSize as number + vimState.editor.options.tabSize as number, ); subsArr.push({ @@ -320,7 +320,7 @@ export class SubstituteCommand extends ExCommand { */ private async replaceMatchRange( vimState: VimState, - match: PatternMatch + match: PatternMatch, ): Promise { if (this.arguments.flags.printCount) { return 0; @@ -346,7 +346,7 @@ export class SubstituteCommand extends ExCommand { private async confirmReplacement( vimState: VimState, match: PatternMatch, - replaceText: string + replaceText: string, ): Promise { const cancellationToken = new CancellationTokenSource(); const validSelections: readonly string[] = ['y', 'n', 'a', 'q', 'l']; @@ -355,8 +355,8 @@ export class SubstituteCommand extends ExCommand { `Replace with ${formatDecorationText( replaceText, vimState.editor.options.tabSize as number, - '\\n' - )} (${validSelections.join('/')})?` + '\\n', + )} (${validSelections.join('/')})?`, ); const newConfirmationSearchHighlights = @@ -367,7 +367,7 @@ export class SubstituteCommand extends ExCommand { vimState.editor.setDecorations(decoration.searchMatch, [ensureVisible(match.range)]); vimState.editor.setDecorations( decoration.confirmedSubstitution, - this.confirmedSubstitutions ?? [] + this.confirmedSubstitutions ?? [], ); await window.showInputBox( { @@ -382,7 +382,7 @@ export class SubstituteCommand extends ExCommand { return prompt; }, }, - cancellationToken.token + cancellationToken.token, ); if (selection === 'q' || selection === 'l' || !selection) { @@ -402,7 +402,7 @@ export class SubstituteCommand extends ExCommand { before: { contentText: formatDecorationText( replaceText, - vimState.editor.options.tabSize as number + vimState.editor.options.tabSize as number, ), }, }, @@ -481,7 +481,7 @@ export class SubstituteCommand extends ExCommand { lineRange: new LineRange( new Address({ type: 'number', num: start + 1 }), ',', - new Address({ type: 'number', num: end + 1 }) + new Address({ type: 'number', num: end + 1 }), ), }) ?? []; @@ -539,7 +539,7 @@ export class SubstituteCommand extends ExCommand { document: vimState.document, position: cursor, }), - Jump.fromStateNow(vimState) + Jump.fromStateNow(vimState), ); vimState.recordedState.transformer.moveCursor(PositionDiff.exactPosition(cursor), 0); } @@ -556,7 +556,7 @@ export class SubstituteCommand extends ExCommand { SearchDirection.Forward, vimState.cursorStopPosition, pattern?.patternString, - {} + {}, ); } } @@ -565,21 +565,21 @@ export class SubstituteCommand extends ExCommand { if (substitutions === 0) { StatusBar.displayError( vimState, - VimError.fromCode(ErrorCode.PatternNotFound, this.arguments.pattern?.patternString) + VimError.fromCode(ErrorCode.PatternNotFound, this.arguments.pattern?.patternString), ); } else if (this.arguments.flags.printCount) { StatusBar.setText( vimState, `${substitutions} match${substitutions > 1 ? 'es' : ''} on ${lines} line${ lines > 1 ? 's' : '' - }` + }`, ); } else if (substitutions > configuration.report) { StatusBar.setText( vimState, `${substitutions} substitution${substitutions > 1 ? 's' : ''} on ${lines} line${ lines > 1 ? 's' : '' - }` + }`, ); } } diff --git a/src/cmd_line/commands/tab.ts b/src/cmd_line/commands/tab.ts index 509479f65..8002d8134 100644 --- a/src/cmd_line/commands/tab.ts +++ b/src/cmd_line/commands/tab.ts @@ -79,31 +79,31 @@ export class TabCommand extends ExCommand { bnext: seq( bangParser, optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(numberParser).fallback(undefined) + optWhitespace.then(numberParser).fallback(undefined), ).map(([bang, cmd, count]) => { return new TabCommand({ type: TabCommandType.Next, bang, cmd, count }); }), bprev: seq( bangParser, optWhitespace.then(fileCmdParser).fallback(undefined), - optWhitespace.then(numberParser).fallback(undefined) + optWhitespace.then(numberParser).fallback(undefined), ).map(([bang, cmd, count]) => { return new TabCommand({ type: TabCommandType.Previous, bang, cmd, count }); }), tabclose: seq(bangParser, optWhitespace.then(numberParser).fallback(undefined)).map( ([bang, count]) => { return new TabCommand({ type: TabCommandType.Close, bang, count }); - } + }, ), tabonly: seq(bangParser, optWhitespace.then(numberParser).fallback(undefined)).map( ([bang, count]) => { return new TabCommand({ type: TabCommandType.Only, bang, count }); - } + }, ), tabnew: seq( optWhitespace.then(fileOptParser).fallback([]), optWhitespace.then(fileCmdParser).fallback(undefined), - regexp(/\S+/).fallback(undefined) + regexp(/\S+/).fallback(undefined), ).map(([opt, cmd, file]) => { return new TabCommand({ type: TabCommandType.New, @@ -116,10 +116,10 @@ export class TabCommand extends ExCommand { .then( seq( alt<'right' | 'left'>(string('+').result('right'), string('-').result('left')).fallback( - undefined + undefined, ), - numberParser.fallback(undefined) - ) + numberParser.fallback(undefined), + ), ) .map(([direction, count]) => new TabCommand({ type: TabCommandType.Move, direction, count })), }; @@ -142,7 +142,7 @@ export class TabCommand extends ExCommand { if (this.arguments.count !== undefined && this.arguments.count >= 0) { await vscode.commands.executeCommand( 'workbench.action.openEditorAtIndex', - this.arguments.count + this.arguments.count, ); } break; @@ -172,7 +172,7 @@ export class TabCommand extends ExCommand { await this.executeCommandWithCount( this.arguments.count || 1, - 'workbench.action.previousEditorInGroup' + 'workbench.action.previousEditorInGroup', ); break; case TabCommandType.First: diff --git a/src/cmd_line/commands/wall.ts b/src/cmd_line/commands/wall.ts index 75aa08a1d..38a06ac75 100644 --- a/src/cmd_line/commands/wall.ts +++ b/src/cmd_line/commands/wall.ts @@ -10,7 +10,7 @@ import { bangParser } from '../../vimscript/parserUtils'; // export class WallCommand extends ExCommand { public static readonly argParser: Parser = bangParser.map( - (bang) => new WallCommand(bang) + (bang) => new WallCommand(bang), ); private readonly bang: boolean; diff --git a/src/cmd_line/commands/write.ts b/src/cmd_line/commands/write.ts index 47429c790..5b1a6e937 100644 --- a/src/cmd_line/commands/write.ts +++ b/src/cmd_line/commands/write.ts @@ -8,13 +8,12 @@ import { ExCommand } from '../../vimscript/exCommand'; import { all, alt, optWhitespace, Parser, regexp, seq, string } from 'parsimmon'; import { bangParser, fileNameParser, FileOpt, fileOptParser } from '../../vimscript/parserUtils'; -export type IWriteCommandArguments = - | { - bang: boolean; - opt: FileOpt; - bgWrite: boolean; - file?: string; - } & ({ cmd: string } | {}); +export type IWriteCommandArguments = { + bang: boolean; + opt: FileOpt; + bgWrite: boolean; + file?: string; +} & ({ cmd: string } | {}); // // Implements :write @@ -32,9 +31,9 @@ export class WriteCommand extends ExCommand { }), fileNameParser.map((file) => { return { file }; - }) + }), // TODO: Support `:help :w_a` ('>>') - ).fallback({}) + ).fallback({}), ).map(([bang, opt, other]) => new WriteCommand({ bang, opt, bgWrite: true, ...other })); public override isRepeatableWithDot = false; @@ -107,7 +106,7 @@ export class WriteCommand extends ExCommand { `File "${fileName}" already exists. Do you want to overwrite it?`, { modal: true }, 'Yes', - 'No' + 'No', ); if (confirmOverwrite === 'No') { @@ -124,7 +123,7 @@ export class WriteCommand extends ExCommand { vimState, `"${fileName}" ${fileExists ? '' : '[New]'} ${vimState.document.lineCount}L ${ vimState.document.getText().length - }C written` + }C written`, ); } catch (e) { StatusBar.setText(vimState, e.message); @@ -139,13 +138,13 @@ export class WriteCommand extends ExCommand { vimState, `"${path.basename(vimState.document.fileName)}" ${vimState.document.lineCount}L ${ vimState.document.getText().length - }C written` + }C written`, ); } else { Logger.warn(':w failed'); // TODO: What's the right thing to do here? } - }) + }), ); } diff --git a/src/cmd_line/commands/writequit.ts b/src/cmd_line/commands/writequit.ts index 689085b32..0a0e9cd9a 100644 --- a/src/cmd_line/commands/writequit.ts +++ b/src/cmd_line/commands/writequit.ts @@ -19,7 +19,7 @@ export class WriteQuitCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser.skip(optWhitespace), fileOptParser.skip(optWhitespace), - fileNameParser.fallback(undefined) + fileNameParser.fallback(undefined), ).map(([bang, opt, file]) => new WriteQuitCommand(file ? { bang, opt, file } : { bang, opt })); public override isRepeatableWithDot = false; diff --git a/src/cmd_line/commands/writequitall.ts b/src/cmd_line/commands/writequitall.ts index d47adcd9d..64c1cb2a9 100644 --- a/src/cmd_line/commands/writequitall.ts +++ b/src/cmd_line/commands/writequitall.ts @@ -17,7 +17,7 @@ export interface IWriteQuitAllCommandArguments { export class WriteQuitAllCommand extends ExCommand { public static readonly argParser: Parser = seq( bangParser, - whitespace.then(fileOptParser).fallback([]) + whitespace.then(fileOptParser).fallback([]), ).map(([bang, fileOpt]) => new WriteQuitAllCommand({ bang, fileOpt })); public override isRepeatableWithDot = false; diff --git a/src/cmd_line/commands/yank.ts b/src/cmd_line/commands/yank.ts index 6540130c2..2a4b4c480 100644 --- a/src/cmd_line/commands/yank.ts +++ b/src/cmd_line/commands/yank.ts @@ -21,15 +21,15 @@ export class YankCommand extends ExCommand { seq(any.fallback(undefined), whitespace.then(numberParser).fallback(undefined)).map( ([register, count]) => { return { register, count }; - } - ) + }, + ), ).map( ({ register, count }) => new YankCommand({ register, count, - }) - ) + }), + ), ); private readonly arguments: YankCommandArguments; diff --git a/src/cmd_line/expression.ts b/src/cmd_line/expression.ts index 4969b19cc..aba0f23e6 100644 --- a/src/cmd_line/expression.ts +++ b/src/cmd_line/expression.ts @@ -23,7 +23,7 @@ const RangeExpression: Expression = { optWhitespace, ['step', string(',').then(optWhitespace).then(integerParser).fallback(1)], optWhitespace, - string(')') + string(')'), ).map(({ start, end, step }): string => { const numbers = range(start, end, step); if (numbers.length === 0) { @@ -42,5 +42,5 @@ export const expressionParser = seqObj<{ register: string; fromExpression: strin optWhitespace, ['register', EXPRESSION_REGISTER], optWhitespace, - ['fromExpression', altExpressions] + ['fromExpression', altExpressions], ); diff --git a/src/common/matching/matcher.ts b/src/common/matching/matcher.ts index f0c78da47..0ac4c63f0 100644 --- a/src/common/matching/matcher.ts +++ b/src/common/matching/matcher.ts @@ -42,7 +42,7 @@ export class PairMatcher { stackHeight: number, isNextMatchForward: boolean, vimState: VimState, - allowCurrentPosition: boolean + allowCurrentPosition: boolean, ): Position | undefined { let lineNumber = position.line; const linePosition = position.character; @@ -139,7 +139,7 @@ export class PairMatcher { position: Position, charToMatch: string, vimState: VimState, - allowCurrentPosition: boolean + allowCurrentPosition: boolean, ): Position | undefined { /** * We do a fairly basic implementation that only tracks the state of the type of @@ -169,7 +169,7 @@ export class PairMatcher { stackHeight, pairing.isNextMatchForward, vimState, - allowCurrentPosition + allowCurrentPosition, ); } } diff --git a/src/common/matching/tagMatcher.ts b/src/common/matching/tagMatcher.ts index 69572a9c9..9c35ca4ea 100644 --- a/src/common/matching/tagMatcher.ts +++ b/src/common/matching/tagMatcher.ts @@ -78,7 +78,7 @@ export class TagMatcher { const firstNonWhitespacePositionOnLine = TextEditor.getFirstNonWhitespaceCharOnLine( vimState.document, - vimState.cursorStartPosition.line + vimState.cursorStartPosition.line, ); /** @@ -109,7 +109,7 @@ export class TagMatcher { const nodeSurrounding = this.determineRelevantTag( tagsSurrounding, startPosOffset, - vimState.cursorStartPosition.compareTo(vimState.cursorStopPosition) !== 0 + vimState.cursorStartPosition.compareTo(vimState.cursorStopPosition) !== 0, ); if (!nodeSurrounding) { @@ -140,7 +140,7 @@ export class TagMatcher { determineRelevantTag( tagsSurrounding: MatchedTag[], adjustedStartPosOffset: number, - selectionActive: boolean + selectionActive: boolean, ): MatchedTag | undefined { const relevantTag = tagsSurrounding[0]; diff --git a/src/common/motion/position.ts b/src/common/motion/position.ts index 1f2238943..4125b1155 100644 --- a/src/common/motion/position.ts +++ b/src/common/motion/position.ts @@ -163,7 +163,7 @@ declare module 'vscode' { */ prevWordStart( document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position; /** @@ -174,7 +174,7 @@ declare module 'vscode' { */ nextWordStart( document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position; /** @@ -192,7 +192,7 @@ declare module 'vscode' { */ nextWordEnd( document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position; getSentenceBegin(args: { forward: boolean }): Position; @@ -264,7 +264,7 @@ Position.prototype.add = function ( this: Position, document: vscode.TextDocument, diff: PositionDiff, - boundsCheck = true + boundsCheck = true, ): Position { if (diff.type === PositionDiffType.ExactPosition) { return new Position(diff.line, diff.character); @@ -318,7 +318,7 @@ Position.prototype.getLeft = function (this: Position, count = 1): Position { Position.prototype.getRight = function (this: Position, count = 1): Position { return new Position( this.line, - Math.min(this.character + count, TextEditor.getLineLength(this.line)) + Math.min(this.character + count, TextEditor.getLineLength(this.line)), ); }; @@ -348,7 +348,7 @@ Position.prototype.getUp = function (this: Position, count = 1): Position { */ Position.prototype.getLeftThroughLineBreaks = function ( this: Position, - includeEol = true + includeEol = true, ): Position { if (!this.isLineBeginning()) { return this.getLeft(); @@ -368,7 +368,7 @@ Position.prototype.getLeftThroughLineBreaks = function ( Position.prototype.getRightThroughLineBreaks = function ( this: Position, - includeEol = false + includeEol = false, ): Position { if (this.isAtDocumentEnd()) { return this; @@ -389,7 +389,7 @@ Position.prototype.getRightThroughLineBreaks = function ( Position.prototype.getOffsetThroughLineBreaks = function ( this: Position, - offset: number + offset: number, ): Position { let pos = new Position(this.line, this.character); @@ -409,7 +409,7 @@ Position.prototype.getOffsetThroughLineBreaks = function ( Position.prototype.prevWordStart = function ( this: Position, document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position { return prevWordStart(document, this, args?.wordType ?? WordType.Normal, args?.inclusive ?? false); }; @@ -417,7 +417,7 @@ Position.prototype.prevWordStart = function ( Position.prototype.nextWordStart = function ( this: Position, document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position { return nextWordStart(document, this, args?.wordType ?? WordType.Normal, args?.inclusive ?? false); }; @@ -425,7 +425,7 @@ Position.prototype.nextWordStart = function ( Position.prototype.prevWordEnd = function ( this: Position, document: vscode.TextDocument, - args?: { wordType?: WordType } + args?: { wordType?: WordType }, ): Position { return prevWordEnd(document, this, args?.wordType ?? WordType.Normal); }; @@ -433,14 +433,14 @@ Position.prototype.prevWordEnd = function ( Position.prototype.nextWordEnd = function ( this: Position, document: vscode.TextDocument, - args?: { wordType?: WordType; inclusive?: boolean } + args?: { wordType?: WordType; inclusive?: boolean }, ): Position { return nextWordEnd(document, this, args?.wordType ?? WordType.Normal, args?.inclusive ?? false); }; Position.prototype.getSentenceBegin = function ( this: Position, - args: { forward: boolean } + args: { forward: boolean }, ): Position { return getSentenceBegin(this, args); }; @@ -462,7 +462,7 @@ Position.prototype.getLineBegin = function (this: Position): Position { */ Position.prototype.getLineBeginRespectingIndent = function ( this: Position, - document: vscode.TextDocument + document: vscode.TextDocument, ): Position { if (!configuration.autoindent) { return this.getLineBegin(); @@ -508,7 +508,7 @@ Position.prototype.advancePositionByText = function (this: Position, text: strin } else { return new Position( this.line + newlines.length, - text.length - (newlines[newlines.length - 1] + 1) + text.length - (newlines[newlines.length - 1] + 1), ); } }; @@ -529,7 +529,7 @@ Position.prototype.isLineEnd = function (this: Position): boolean { Position.prototype.isFirstWordOfLine = function ( this: Position, - document: vscode.TextDocument + document: vscode.TextDocument, ): boolean { return ( TextEditor.getFirstNonWhitespaceCharOnLine(document, this.line).character === this.character @@ -550,7 +550,7 @@ Position.prototype.isAtDocumentEnd = function (this: Position): boolean { */ Position.prototype.isInLeadingWhitespace = function ( this: Position, - document: vscode.TextDocument + document: vscode.TextDocument, ): boolean { return /^\s+$/.test(document.getText(new vscode.Range(this.getLineBegin(), this))); }; @@ -560,7 +560,7 @@ Position.prototype.isInLeadingWhitespace = function ( */ Position.prototype.obeyStartOfLine = function ( this: Position, - document: vscode.TextDocument + document: vscode.TextDocument, ): Position { return configuration.startofline ? TextEditor.getFirstNonWhitespaceCharOnLine(document, this.line) diff --git a/src/common/number/numericString.ts b/src/common/number/numericString.ts index c66b41609..d39e6c378 100644 --- a/src/common/number/numericString.ts +++ b/src/common/number/numericString.ts @@ -63,7 +63,7 @@ export class NumericString { // Return parse result and offset of suffix public static parse( input: string, - targetRadix?: NumericStringRadix + targetRadix?: NumericStringRadix, ): { num: NumericString; suffixOffset: number } | undefined { const filteredMatchings = targetRadix !== undefined @@ -149,7 +149,7 @@ export class NumericString { prefix: string, suffix: string, negative: boolean, - isCapital: boolean + isCapital: boolean, ) { this.value = value; this.radix = radix; diff --git a/src/completion/lineCompletionProvider.ts b/src/completion/lineCompletionProvider.ts index bcbfa2a43..6f1aeaa71 100644 --- a/src/completion/lineCompletionProvider.ts +++ b/src/completion/lineCompletionProvider.ts @@ -29,7 +29,7 @@ const documentsStartingWith = (startingFileName: string) => { const linesWithoutIndentation = ( document: vscode.TextDocument, lineToStartScanFrom: number, - scanAboveFirst: boolean + scanAboveFirst: boolean, ): Array<{ sortPriority: number; text: string }> => { const distanceFromStartLine = (line: number) => { let sortPriority = scanAboveFirst ? lineToStartScanFrom - line : line - lineToStartScanFrom; @@ -68,7 +68,7 @@ const linesWithoutIndentation = ( const getCompletionsForText = ( text: string, currentFileName: string, - currentPosition: Position + currentPosition: Position, ): string[] | null => { const matchedLines: string[] = []; @@ -115,10 +115,10 @@ const getCompletionsForText = ( */ export const getCompletionsForCurrentLine = ( position: Position, - document: vscode.TextDocument + document: vscode.TextDocument, ): string[] | null => { const currentLineText = document.getText( - new vscode.Range(TextEditor.getFirstNonWhitespaceCharOnLine(document, position.line), position) + new vscode.Range(TextEditor.getFirstNonWhitespaceCharOnLine(document, position.line), position), ); return getCompletionsForText(currentLineText, document.fileName, position); @@ -160,8 +160,8 @@ export const lineCompletionProvider = { vimState.recordedState.transformer.delete( new vscode.Range( TextEditor.getFirstNonWhitespaceCharOnLine(vimState.document, position.line), - position.getLineEnd() - ) + position.getLineEnd(), + ), ); vimState.recordedState.transformer.addTransformation({ diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index 5353b1684..660592559 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -544,7 +544,7 @@ function overlapSetting(args: { this.getConfiguration('editor').update( args.settingName, value, - vscode.ConfigurationTarget.Global + vscode.ConfigurationTarget.Global, ); }, enumerable: true, diff --git a/src/configuration/remapper.ts b/src/configuration/remapper.ts index 07069164b..9c09ec51c 100644 --- a/src/configuration/remapper.ts +++ b/src/configuration/remapper.ts @@ -124,7 +124,7 @@ export class Remapper implements IRemapper { Logger.trace( `trying to find matching remap. keys=${keys}. mode=${ Mode[vimState.currentMode] - }. keybindings=${this.configKey}.` + }. keybindings=${this.configKey}.`, ); let remapping: IKeyRemapping | undefined = this.findMatchingRemap(userDefinedRemappings, keys); @@ -206,11 +206,11 @@ export class Remapper implements IRemapper { keys.push(SpecialKeys.TimeoutFinished); // include the '' key Logger.trace( - `${this.configKey}. timeout finished, handling timed out buffer keys without allowing a new timeout.` + `${this.configKey}. timeout finished, handling timed out buffer keys without allowing a new timeout.`, ); } Logger.trace( - `${this.configKey}. potential remap broken. resending keys without allowing a potential remap on first key. keys=${keys}` + `${this.configKey}. potential remap broken. resending keys without allowing a potential remap on first key. keys=${keys}`, ); this.hasPotentialRemap = false; vimState.recordedState.allowPotentialRemapOnFirstKey = false; @@ -229,7 +229,7 @@ export class Remapper implements IRemapper { } catch (e) { if (e instanceof ForceStopRemappingError) { Logger.trace( - `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}` + `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}`, ); } } finally { @@ -266,12 +266,12 @@ export class Remapper implements IRemapper { this.hasAmbiguousRemap = remapping; Logger.trace( - `${this.configKey}. ambiguous match found. before=${remapping.before}. after=${remapping.after}. command=${remapping.commands}. waiting for other key or timeout to finish.` + `${this.configKey}. ambiguous match found. before=${remapping.before}. after=${remapping.after}. command=${remapping.commands}. waiting for other key or timeout to finish.`, ); } else { this.hasPotentialRemap = true; Logger.trace( - `${this.configKey}. potential remap found. waiting for other key or timeout to finish.` + `${this.configKey}. potential remap found. waiting for other key or timeout to finish.`, ); } @@ -333,7 +333,7 @@ export class Remapper implements IRemapper { remapState.mapDepth++; Logger.trace( - `${this.configKey}. match found. before=${remapping.before}. after=${remapping.after}. command=${remapping.commands}. remainingKeys=${remainingKeys}. mapDepth=${remapState.mapDepth}.` + `${this.configKey}. match found. before=${remapping.before}. after=${remapping.after}. command=${remapping.commands}. remainingKeys=${remainingKeys}. mapDepth=${remapState.mapDepth}.`, ); let remapFailed = false; @@ -377,12 +377,12 @@ export class Remapper implements IRemapper { } Logger.trace( - `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}` + `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}`, ); } else { // If some other error happens during the remapping handling it should stop the remap and rethrow Logger.trace( - `${this.configKey}. error found in the middle of remapping, ignoring the rest of the remap. error: ${e}` + `${this.configKey}. error found in the middle of remapping, ignoring the rest of the remap. error: ${e}`, ); throw e; } @@ -440,7 +440,7 @@ export class Remapper implements IRemapper { await modeHandler.handleMultipleKeyEvents(remainingKeys); } catch (e) { Logger.trace( - `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}` + `${this.configKey}. Stopped the remapping in the middle, ignoring the rest. Reason: ${e.message}`, ); } finally { remapState.isCurrentlyPerformingRecursiveRemapping = false; @@ -466,7 +466,7 @@ export class Remapper implements IRemapper { private async handleRemapping( remapping: IKeyRemapping, modeHandler: ModeHandler, - skipFirstCharacter: boolean + skipFirstCharacter: boolean, ) { const { vimState, remapState } = modeHandler; @@ -531,7 +531,7 @@ export class Remapper implements IRemapper { protected findMatchingRemap( userDefinedRemappings: Map, - inputtedKeys: string[] + inputtedKeys: string[], ): IKeyRemapping | undefined { if (userDefinedRemappings.size === 0) { return undefined; @@ -563,7 +563,7 @@ export class Remapper implements IRemapper { * @param remappings */ protected static getRemappedKeysLengthRange( - remappings: ReadonlyMap + remappings: ReadonlyMap, ): [number, number] { if (remappings.size === 0) { return [0, 0]; @@ -581,7 +581,7 @@ export class Remapper implements IRemapper { protected static hasPotentialRemap( keys: string[], remappings: ReadonlyMap, - countRemapAsPotential: boolean = false + countRemapAsPotential: boolean = false, ): boolean { const keysAsString = keys.join(''); const re = /^<([^>]+)>/; diff --git a/src/configuration/validators/remappingValidator.ts b/src/configuration/validators/remappingValidator.ts index f71d2643c..5e9db4b55 100644 --- a/src/configuration/validators/remappingValidator.ts +++ b/src/configuration/validators/remappingValidator.ts @@ -28,7 +28,7 @@ export class RemappingValidator implements IConfigurationValidator { // because we process keybindings backwards in next loop, user mapping will override for (const pluginMapping of PluginDefaultMappings.getPluginDefaultMappings( modeKeyBindingsKey, - config + config, )) { // note concat(all mappings) does not work somehow keybindings.push(pluginMapping); @@ -59,13 +59,13 @@ export class RemappingValidator implements IConfigurationValidator { // normalize if (remapping.before) { remapping.before.forEach( - (key, idx) => (remapping.before[idx] = Notation.NormalizeKey(key, config.leader)) + (key, idx) => (remapping.before[idx] = Notation.NormalizeKey(key, config.leader)), ); } if (remapping.after) { remapping.after.forEach( - (key, idx) => (remapping.after![idx] = Notation.NormalizeKey(key, config.leader)) + (key, idx) => (remapping.after![idx] = Notation.NormalizeKey(key, config.leader)), ); } @@ -159,7 +159,7 @@ export class RemappingValidator implements IConfigurationValidator { private async getCommandMap(): Promise> { if (this.commandMap == null) { this.commandMap = new Map( - (await vscode.commands.getCommands(true)).map((x) => [x, true] as [string, boolean]) + (await vscode.commands.getCommands(true)).map((x) => [x, true] as [string, boolean]), ); } return this.commandMap; diff --git a/src/configuration/vimrc.ts b/src/configuration/vimrc.ts index e2b7a5f68..6269c0817 100644 --- a/src/configuration/vimrc.ts +++ b/src/configuration/vimrc.ts @@ -320,7 +320,7 @@ export class VimrcImpl { // Don't remove a mapping present in settings.json; those are more specific to VSCodeVim. _.remove( remaps, - (r) => r.source === 'vimrc' && _.isEqual(r.before, remap.keyRemapping.before) + (r) => r.source === 'vimrc' && _.isEqual(r.before, remap.keyRemapping.before), ); }); return true; diff --git a/src/configuration/vimrcKeyRemappingBuilder.ts b/src/configuration/vimrcKeyRemappingBuilder.ts index 9b42dcd7b..f15b496a5 100644 --- a/src/configuration/vimrcKeyRemappingBuilder.ts +++ b/src/configuration/vimrcKeyRemappingBuilder.ts @@ -139,7 +139,7 @@ class VimrcKeyRemappingBuilderImpl { */ public async build( line: string, - vscodeCommands: string[] + vscodeCommands: string[], ): Promise { const matches = VimrcKeyRemappingBuilderImpl.KEY_REMAPPING_REG_EX.exec(line); if (!matches || matches.length < 4) { diff --git a/src/history/historyTracker.ts b/src/history/historyTracker.ts index 065d7e07d..1fea94527 100644 --- a/src/history/historyTracker.ts +++ b/src/history/historyTracker.ts @@ -189,7 +189,7 @@ class HistoryStep { current = DocumentChange.replace( first.start, first.before + second.before.slice(intersectLength), - first.after.slice(0, first.after.length - intersectLength) + second.after + first.after.slice(0, first.after.length - intersectLength) + second.after, ); } else { merged.push(current); @@ -448,12 +448,12 @@ export class HistoryTracker { if (ch === '\n') { newMark.position = new Position( Math.max(newMark.position.line - 1, 0), - newMark.position.character + newMark.position.character, ); } else if (pos.line === newMark.position.line) { newMark.position = new Position( newMark.position.line, - Math.max(newMark.position.character - 1, 0) + Math.max(newMark.position.character - 1, 0), ); } } @@ -476,12 +476,12 @@ export class HistoryTracker { if (ch === '\n') { newMark.position = new Position( newMark.position.line + 1, - newMark.position.character + newMark.position.character, ); } else if (pos.line === newMark.position.line) { newMark.position = new Position( newMark.position.line, - newMark.position.character + 1 + newMark.position.character + 1, ); } } @@ -610,7 +610,7 @@ export class HistoryTracker { this.undoStack.removeMarks(markNames); HistoryStep.globalMarks = HistoryStep.globalMarks.filter( - (mark) => mark.name === '' || !markNames.includes(mark.name) + (mark) => mark.name === '' || !markNames.includes(mark.name), ); } @@ -686,7 +686,7 @@ export class HistoryTracker { this.undoStack.pushChange( added ? DocumentChange.insert(currentPosition, text) - : DocumentChange.delete(currentPosition, text) + : DocumentChange.delete(currentPosition, text), ); } @@ -762,7 +762,9 @@ export class HistoryTracker { const changes = step.changes.length === 1 ? `1 change` : `${step.changes.length} changes`; StatusBar.setText( this.vimState, - `${changes}; before #${this.undoStack.getCurrentHistoryStepIndex() + 1} ${step.howLongAgo()}` + `${changes}; before #${ + this.undoStack.getCurrentHistoryStepIndex() + 1 + } ${step.howLongAgo()}`, ); return step.cursorStart; @@ -789,7 +791,7 @@ export class HistoryTracker { const changes = step.changes.length === 1 ? `1 change` : `${step.changes.length} changes`; StatusBar.setText( this.vimState, - `${changes}; after #${this.undoStack.getCurrentHistoryStepIndex()} ${step.howLongAgo()}` + `${changes}; after #${this.undoStack.getCurrentHistoryStepIndex()} ${step.howLongAgo()}`, ); return step.cursorStart; @@ -836,7 +838,7 @@ export class HistoryTracker { // Modify & replace the change to avoid undoing the newline embedded in the change change = DocumentChange.insert( new Position(change.start.line + 1, 0), - change.after.slice(change.after.lastIndexOf('\n')) + change.after.slice(change.after.lastIndexOf('\n')), ); done = true; } else if (newlines.length > 0 || change.start.line !== undoLine) { diff --git a/src/jumps/jumpTracker.ts b/src/jumps/jumpTracker.ts index e783c096f..8edf746d1 100644 --- a/src/jumps/jumpTracker.ts +++ b/src/jumps/jumpTracker.ts @@ -132,7 +132,7 @@ export class JumpTracker { } else { // Get jump file from visible editors const editor: vscode.TextEditor = vscode.window.visibleTextEditors.filter( - (e) => e.document.fileName === jump.fileName + (e) => e.document.fileName === jump.fileName, )[0]; if (editor) { @@ -158,7 +158,7 @@ export class JumpTracker { private async jumpThroughHistory( getJump: (j: Jump) => Jump, position: Position, - vimState: VimState + vimState: VimState, ): Promise { let jump = new Jump({ document: vimState.document, @@ -326,13 +326,14 @@ export class JumpTracker { new Jump({ document: jump.document, position: newPosition, - }) + }), ); } private clearJumpsOnSameLine(jump: Jump): void { this._jumps = this._jumps.filter( - (j) => j === jump || !(j.fileName === jump.fileName && j.position.line === jump.position.line) + (j) => + j === jump || !(j.fileName === jump.fileName && j.position.line === jump.position.line), ); } diff --git a/src/mode/mode.ts b/src/mode/mode.ts index fdd14c2db..65ea738cf 100644 --- a/src/mode/mode.ts +++ b/src/mode/mode.ts @@ -39,7 +39,7 @@ export function isVisualMode(mode: Mode): mode is Mode.Visual | Mode.VisualLine * This means SearchInProgess and CommandlineInProgress modes. */ export function isStatusBarMode( - mode: Mode + mode: Mode, ): mode is Mode.CommandlineInProgress | Mode.SearchInProgressMode { return [Mode.SearchInProgressMode, Mode.CommandlineInProgress].includes(mode); } diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 76023797e..e76393b69 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -111,7 +111,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { public static async create( handlerMap: IModeHandlerMap, - textEditor: vscode.TextEditor + textEditor: vscode.TextEditor, ): Promise { const modeHandler = new ModeHandler(handlerMap, textEditor); await modeHandler.vimState.load(); @@ -152,7 +152,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { } this.vimState.cursors = selections.map(({ active, anchor }) => - active.isBefore(anchor) ? new Cursor(anchor.getLeft(), active) : new Cursor(anchor, active) + active.isBefore(anchor) ? new Cursor(anchor.getLeft(), active) : new Cursor(anchor, active), ); } @@ -195,7 +195,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { Logger.debug( `Selection change: ${selection.anchor.toString()}, ${selection.active}, SelectionsLength: ${ e.selections.length - }` + }`, ); // If our previous cursors are not included on any of the current selections, then a snippet @@ -220,8 +220,8 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { new Cursor( // Adjust the cursor positions because cursors & selections don't match exactly sel.anchor.isAfter(sel.active) ? sel.anchor.getLeft() : sel.anchor, - sel.active - ) + sel.active, + ), ); if ( e.selections.some((s) => !s.anchor.isEqual(s.active)) && @@ -288,7 +288,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { const cursorEnd = laterOf( this.vimState.cursorStartPosition, - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); if (e.textEditor.document.validatePosition(cursorEnd).isBefore(cursorEnd)) { // The document changed such that our cursor position is now out of bounds, possibly by @@ -317,7 +317,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { Logger.debug( `Selections: Changing Cursors from selection handler... ${selection.anchor.toString()}, ${ selection.active - }` + }`, ); this.vimState.cursorStopPosition = selection.active; this.vimState.cursorStartPosition = selection.anchor; @@ -492,7 +492,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { ) { handledAsRemap = await this.remappers.sendKey( this.vimState.recordedState.commandList, - this + this, ); } @@ -666,7 +666,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // Push document content change to the stack lastAction.addChanges( this.vimState.historyTracker.currentContentChanges, - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); this.vimState.historyTracker.currentContentChanges = []; recordedState.actionsRun.push(action); @@ -676,7 +676,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // This means we are already in Insert Mode but there is still not DocumentContentChangeAction in stack this.vimState.historyTracker.currentContentChanges = []; const newContentChange = new DocumentContentChangeAction( - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); newContentChange.keysPressed.push(key); recordedState.actionsRun.push(newContentChange); @@ -707,7 +707,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { if (action.isJump) { globalState.jumpTracker.recordJump( Jump.fromStateBefore(this.vimState), - Jump.fromStateNow(this.vimState) + Jump.fromStateNow(this.vimState), ); } @@ -723,7 +723,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // position instead of the position sent to VSCode. if (this.vimState.currentMode === Mode.Visual) { this.vimState.cursors = this.vimState.cursors.map((c) => - c.start.isBefore(c.stop) ? c.withNewStop(c.stop.getLeftThroughLineBreaks(true)) : c + c.start.isBefore(c.stop) ? c.withNewStop(c.stop.getLeftThroughLineBreaks(true)) : c, ); } @@ -733,8 +733,8 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { (c) => new Cursor( this.vimState.document.validatePosition(c.start), - this.vimState.document.validatePosition(c.stop) - ) + this.vimState.document.validatePosition(c.stop), + ), ); let ranRepeatableAction = false; @@ -851,9 +851,9 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.cursors = this.vimState.cursors.map((c) => c.start.isBeforeOrEqual(c.stop) ? c.withNewStop( - c.stop.isLineEnd() ? c.stop.getRightThroughLineBreaks() : c.stop.getRight() + c.stop.isLineEnd() ? c.stop.getRightThroughLineBreaks() : c.stop.getRight(), ) - : c + : c, ); } @@ -895,7 +895,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // If we're in Normal mode, collapse each cursor down to one character if (this.currentMode === Mode.Normal) { this.vimState.cursors = this.vimState.cursors.map( - (cursor) => new Cursor(cursor.stop, cursor.stop) + (cursor) => new Cursor(cursor.stop, cursor.stop), ); } @@ -929,7 +929,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { isVisualMode(this.vimState.currentMode) && currentLineLength > 0 ? 1 : 0; if (cursor.start.character >= currentStartLineLength) { cursor = cursor.withNewStart( - cursor.start.withColumn(Math.max(currentStartLineLength - 1, 0)) + cursor.start.withColumn(Math.max(currentStartLineLength - 1, 0)), ); } @@ -982,14 +982,14 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { const result = await movement.execActionWithCount( cursorPosition, this.vimState, - recordedState.count + recordedState.count, ); // We also need to update the specific cursor, in case the cursor position was modified inside // the handling functions (e.g. 'it') this.vimState.cursors[i] = new Cursor( this.vimState.cursorStartPosition, - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); this.vimState.cursorStartPosition = oldCursorPositionStart; @@ -1094,7 +1094,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { const resultingCursor = new Cursor( this.vimState.cursorStartPosition, - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); resultingCursors.push(resultingCursor); @@ -1118,7 +1118,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { if (this.vimState.lastVisualSelection) { this.vimState.dotCommandPreviousVisualSelection = new vscode.Selection( this.vimState.lastVisualSelection.start, - this.vimState.lastVisualSelection.end + this.vimState.lastVisualSelection.end, ); } @@ -1198,7 +1198,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { } // If there are no decorations from the command line, get decorations for previous SearchState decorations = getDecorationsForSearchMatchRanges( - globalState.searchState.getMatchRanges(this.vimState) + globalState.searchState.getMatchRanges(this.vimState), ); this.searchDecorationCacheKey = { searchString: globalState.searchState.searchString, @@ -1209,16 +1209,16 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.editor.setDecorations( decoration.searchHighlight, - decorations?.searchHighlight ?? [] + decorations?.searchHighlight ?? [], ); this.vimState.editor.setDecorations(decoration.searchMatch, decorations?.searchMatch ?? []); this.vimState.editor.setDecorations( decoration.substitutionAppend, - decorations?.substitutionAppend ?? [] + decorations?.substitutionAppend ?? [], ); this.vimState.editor.setDecorations( decoration.substitutionReplace, - decorations?.substitutionReplace ?? [] + decorations?.substitutionReplace ?? [], ); } @@ -1226,7 +1226,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { args: { drawSelection: boolean; revealRange: boolean } = { drawSelection: true, revealRange: true, - } + }, ): Promise { // Draw selection (or cursor) if (args.drawSelection) { @@ -1275,8 +1275,8 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { selections.push( new vscode.Selection( this.vimState.document.validatePosition(line.start), - this.vimState.document.validatePosition(line.end) - ) + this.vimState.document.validatePosition(line.end), + ), ); } break; @@ -1312,12 +1312,12 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { ? // Forwards Selection new vscode.Selection( earlierOf(s.anchor, previousSelection.anchor), - laterOf(s.active, previousSelection.active) + laterOf(s.active, previousSelection.active), ) : // Backwards Selection new vscode.Selection( laterOf(s.anchor, previousSelection.anchor), - earlierOf(s.active, previousSelection.active) + earlierOf(s.active, previousSelection.active), ); } else { combinedSelections.push(s); @@ -1338,7 +1338,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { selections.some( (s, i) => !s.anchor.isEqual(this.vimState.editor.selections[i].anchor) || - !s.active.isEqual(this.vimState.editor.selections[i].active) + !s.active.isEqual(this.vimState.editor.selections[i].active), ); if (willTriggerChange) { @@ -1346,13 +1346,13 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { (hash, s) => hash + `[${s.anchor.line}, ${s.anchor.character}; ${s.active.line}, ${s.active.character}]`, - '' + '', ); this.selectionsChanged.ourSelections.push(selectionsHash); Logger.trace( `Adding selection change to be ignored! (total: ${ this.selectionsChanged.ourSelections.length - }) Hash: ${selectionsHash}, Selections: ${selections[0].anchor.toString()}, ${selections[0].active.toString()}` + }) Hash: ${selectionsHash}, Selections: ${selections[0].anchor.toString()}, ${selections[0].active.toString()}`, ); } @@ -1419,7 +1419,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { */ this.vimState.editor.revealRange( new vscode.Range(cursorToTrack.stop, cursorToTrack.stop), - revealType + revealType, ); } } @@ -1430,7 +1430,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { if (!cursorStyle) { const cursorType = getCursorType( this.vimState, - this.vimState.currentModeIncludingPseudoModes + this.vimState.currentModeIncludingPseudoModes, ); cursorStyle = getCursorStyle(cursorType); if ( @@ -1529,7 +1529,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.editor.setDecorations( decoration.insertModeVirtualCharacter, - iModeVirtualCharDecorationOptions + iModeVirtualCharDecorationOptions, ); // OperatorPendingMode half block cursor @@ -1556,7 +1556,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.editor.setDecorations(decoration.operatorPendingModeCursor, opCursorDecorations); this.vimState.editor.setDecorations( decoration.operatorPendingModeCursorChar, - opCursorCharDecorations + opCursorCharDecorations, ); for (const markDecoration of decoration.allMarkDecorations()) { @@ -1597,7 +1597,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { ? [ new vscode.Range( TextEditor.getDocumentBegin(), - TextEditor.getDocumentEnd(this.vimState.document) + TextEditor.getDocumentEnd(this.vimState.document), ), ] : []; @@ -1629,7 +1629,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // Tell VSCode that the cursor position changed, so it updates its highlights for `editor.occurrencesHighlight`. const range = new vscode.Range( this.vimState.cursorStartPosition, - this.vimState.cursorStopPosition + this.vimState.cursorStopPosition, ); if (!/\s+/.test(this.vimState.document.getText(range))) { vscode.commands.executeCommand('editor.action.wordHighlight.trigger'); @@ -1652,7 +1652,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.cursorStopPosition, key, this.vimState, - false + false, ); if (result !== undefined) { if (this.vimState.cursorStopPosition.isEqual(result)) { @@ -1664,7 +1664,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { this.vimState.cursorStopPosition.getLeft(), key, this.vimState, - false + false, ); if (result !== undefined) { if (this.vimState.cursorStopPosition.getLeft(2).isEqual(result)) { diff --git a/src/neovim/neovim.ts b/src/neovim/neovim.ts index 646500309..2bda7481e 100644 --- a/src/neovim/neovim.ts +++ b/src/neovim/neovim.ts @@ -21,7 +21,7 @@ export class NeovimWrapper implements vscode.Disposable { async run( vimState: VimState, - command: string + command: string, ): Promise<{ statusBarText: string; error: boolean }> { if (!this.nvim) { this.nvim = await this.startNeovim(vimState.document); @@ -137,7 +137,7 @@ export class NeovimWrapper implements vscode.Disposable { const [rangeStart, rangeEnd] = sorted( vimState.cursorStartPosition, - vimState.cursorStopPosition + vimState.cursorStopPosition, ); await this.nvim.callFunction('setpos', [ '.', @@ -189,18 +189,18 @@ export class NeovimWrapper implements vscode.Disposable { await TextEditor.replace( vimState.editor, new vscode.Range(0, 0, lineCount - 1, TextEditor.getLineLength(lineCount - 1)), - fixedLines.join('\n') + fixedLines.join('\n'), ); Logger.debug(`${lines.length} lines in nvim. ${lineCount} in editor.`); const [row, character] = ((await this.nvim.callFunction('getpos', ['.'])) as number[]).slice( 1, - 3 + 3, ); vimState.editor.selection = new vscode.Selection( new Position(row - 1, character), - new Position(row - 1, character) + new Position(row - 1, character), ); if (configuration.expandtab) { diff --git a/src/platform/browser/fs.ts b/src/platform/browser/fs.ts index a052570ca..b800b2ce2 100644 --- a/src/platform/browser/fs.ts +++ b/src/platform/browser/fs.ts @@ -92,7 +92,7 @@ export async function mkdirAsync(path: string, options: any): Promise { export async function writeFileAsync( path: string, content: string, - encoding: BufferEncoding + encoding: BufferEncoding, ): Promise { return vscode.workspace.fs.writeFile(vscode.Uri.parse(path), Buffer.from(content)); } diff --git a/src/platform/browser/history.ts b/src/platform/browser/history.ts index eea90181c..a7b86c1f2 100644 --- a/src/platform/browser/history.ts +++ b/src/platform/browser/history.ts @@ -12,7 +12,7 @@ export class HistoryBase { constructor( context: vscode.ExtensionContext, historyFileName: string, - extensionStoragePath: string + extensionStoragePath: string, ) { this.context = context; this.historyFileName = historyFileName; diff --git a/src/platform/node/fs.ts b/src/platform/node/fs.ts index 31216ac53..bb2e062e1 100644 --- a/src/platform/node/fs.ts +++ b/src/platform/node/fs.ts @@ -101,7 +101,7 @@ export async function mkdirAsync(path: string, options: any): Promise { export async function writeFileAsync( path: string, content: string, - encoding: BufferEncoding + encoding: BufferEncoding, ): Promise { await promisify(fs.writeFile)(path, content, encoding); } diff --git a/src/platform/node/history.ts b/src/platform/node/history.ts index 80959e6c9..e9505cfad 100644 --- a/src/platform/node/history.ts +++ b/src/platform/node/history.ts @@ -16,7 +16,7 @@ export class HistoryBase { constructor( context: vscode.ExtensionContext, historyFileName: string, - extensionStoragePath: string + extensionStoragePath: string, ) { this.historyFileName = historyFileName; this.extensionStoragePath = extensionStoragePath; diff --git a/src/register/register.ts b/src/register/register.ts index 1a1f006f1..eb947dbc5 100644 --- a/src/register/register.ts +++ b/src/register/register.ts @@ -55,7 +55,7 @@ export class Register { vimState: VimState, content: RegisterContent, multicursorIndex?: number, - copyToUnnamed?: boolean + copyToUnnamed?: boolean, ): void { const register = vimState.recordedState.registerName; @@ -119,7 +119,7 @@ export class Register { vimState: VimState, register: string, content: RegisterContent, - multicursorIndex: number + multicursorIndex: number, ): void { if (multicursorIndex === 0 || !Register.registers.has(register)) { Register.registers.set(register, []); @@ -148,7 +148,7 @@ export class Register { vimState: VimState, register: string, content: RegisterContent, - multicursorIndex: number + multicursorIndex: number, ): void { if (!Register.registers.has(register)) { Register.registers.set(register, []); @@ -192,7 +192,7 @@ export class Register { */ public static setReadonlyRegister( register: '.' | '%' | ':' | '#' | '/', - content: RegisterContent + content: RegisterContent, ) { Register.registers.set(register, [ { @@ -269,7 +269,7 @@ export class Register { */ public static async get( register: string, - multicursorIndex = 0 + multicursorIndex = 0, ): Promise { if (!Register.isValidRegister(register)) { throw new Error(`Invalid register ${register}`); @@ -329,7 +329,7 @@ export class Register { version: REGISTER_FORMAT_VERSION, registers: serializableRegisters, }), - 'utf8' + 'utf8', ); }); } @@ -345,7 +345,7 @@ export class Register { if (parsed.version === REGISTER_FORMAT_VERSION) { Register.registers = new Map(parsed.registers); } - } + }, ); }); } else { diff --git a/src/state/searchState.ts b/src/state/searchState.ts index ff4eaf417..280413ad1 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -29,7 +29,7 @@ export class SearchState { direction: SearchDirection, startPosition: Position, searchString = '', - { ignoreSmartcase = false } = {} + { ignoreSmartcase = false } = {}, ) { this._searchString = searchString; @@ -124,13 +124,13 @@ export class SearchState { vimState: VimState, startPosition: Position, direction = SearchDirection.Forward, - relativeIndex = 0 + relativeIndex = 0, ): IndexedPosition | undefined { const nextMatch = this.getNextSearchMatchRange( vimState, startPosition, direction, - relativeIndex + relativeIndex, ); if (nextMatch === undefined) { return undefined; @@ -155,7 +155,7 @@ export class SearchState { vimState: VimState, fromPosition: Position, direction = SearchDirection.Forward, - relativeIndex = 0 + relativeIndex = 0, ): IndexedRange | undefined { const matchRanges = this.recalculateSearchRanges(vimState); diff --git a/src/state/vimState.ts b/src/state/vimState.ts index c965f86fa..a46e7cd48 100644 --- a/src/state/vimState.ts +++ b/src/state/vimState.ts @@ -26,7 +26,7 @@ interface IBaseMovement { execActionWithCount( position: Position, vimState: VimState, - count: number + count: number, ): Promise; } @@ -256,7 +256,7 @@ export class VimState implements vscode.Disposable { mode, replaceState: new ReplaceState( this.cursors.map((cursor) => cursor.stop), - this.recordedState.count + this.recordedState.count, ), } : mode === Mode.CommandlineInProgress @@ -275,7 +275,7 @@ export class VimState implements vscode.Disposable { mode, highSurrogate: undefined, } - : { mode } + : { mode }, ); } diff --git a/src/statusBar.ts b/src/statusBar.ts index 309425439..bc9b5a5cf 100644 --- a/src/statusBar.ts +++ b/src/statusBar.ts @@ -21,7 +21,7 @@ class StatusBarImpl implements vscode.Disposable { this.statusBarItem = vscode.window.createStatusBarItem( 'primary', vscode.StatusBarAlignment.Left, - Number.MIN_SAFE_INTEGER // Furthest right on the left + Number.MIN_SAFE_INTEGER, // Furthest right on the left ); this.statusBarItem.name = 'Vim Command Line'; this.statusBarItem.show(); @@ -29,7 +29,7 @@ class StatusBarImpl implements vscode.Disposable { this.recordedStateStatusBarItem = vscode.window.createStatusBarItem( 'showcmd', vscode.StatusBarAlignment.Right, - Number.MAX_SAFE_INTEGER // Furthest left on the right + Number.MAX_SAFE_INTEGER, // Furthest left on the right ); this.recordedStateStatusBarItem.name = 'Vim Pending Command Keys'; this.recordedStateStatusBarItem.show(); diff --git a/src/textEditor.ts b/src/textEditor.ts index be2006ed9..8eee52634 100644 --- a/src/textEditor.ts +++ b/src/textEditor.ts @@ -21,7 +21,7 @@ export class TextEditor { editor: vscode.TextEditor, text: string, at?: Position, - letVSCodeHandleKeystrokes?: boolean + letVSCodeHandleKeystrokes?: boolean, ): Promise { // If we insert "blah(" with default:type, VSCode will insert the closing ). // We *probably* don't want that to happen if we're inserting a lot of text. @@ -46,7 +46,7 @@ export class TextEditor { static async replace( editor: vscode.TextEditor, range: vscode.Range, - text: string + text: string, ): Promise { return editor.edit((editBuilder) => { editBuilder.replace(range, text); @@ -190,7 +190,7 @@ export class TextEditor { */ public static getFirstNonWhitespaceCharOnLine( document: vscode.TextDocument, - line: number + line: number, ): Position { line = clamp(line, 0, document.lineCount - 1); return new Position(line, document.lineAt(line).firstNonWhitespaceCharacterIndex); @@ -205,7 +205,7 @@ export class TextEditor { public static *iterateLinesInBlock( vimState: VimState, cursor?: Cursor, - options: { reverse?: boolean } = { reverse: false } + options: { reverse?: boolean } = { reverse: false }, ): Iterable<{ line: string; start: Position; end: Position }> { const { reverse } = options; @@ -243,7 +243,7 @@ export class TextEditor { */ public static *iterateWords( document: vscode.TextDocument, - start: Position + start: Position, ): Iterable<{ start: Position; end: Position; word: string }> { const text = document.lineAt(start).text; if (/\s/.test(text[start.character])) { diff --git a/src/textobject/sentence.ts b/src/textobject/sentence.ts index 5170662b6..7af2150d3 100644 --- a/src/textobject/sentence.ts +++ b/src/textobject/sentence.ts @@ -18,7 +18,7 @@ export function getSentenceEnd(pos: Position): Position { for (let currentLine = pos.line; currentLine <= paragraphEnd.line; currentLine++) { const allPositions = getAllPositions(TextEditor.getLine(currentLine).text, sentenceEndRegex); const newCharacter = allPositions.find( - (index) => index > pos.character || currentLine !== pos.line + (index) => index > pos.character || currentLine !== pos.line, ); if (newCharacter !== undefined) { @@ -59,7 +59,7 @@ function getNextSentenceBegin(pos: Position): Position { for (let currentLine = pos.line; currentLine <= paragraphEnd.line; currentLine++) { const endPositions = getAllEndPositions(TextEditor.getLine(currentLine).text, sentenceEndRegex); const newCharacter = endPositions.find( - (index) => index > pos.character || currentLine !== pos.line + (index) => index > pos.character || currentLine !== pos.line, ); if (newCharacter !== undefined) { @@ -73,7 +73,7 @@ function getNextSentenceBegin(pos: Position): Position { function getFirstNonWhitespaceInParagraph( pos: Position, paragraphEnd: Position, - inclusive: boolean + inclusive: boolean, ): Position { // If the cursor is at an empty line, it's the end of a paragraph and the begin of another paragraph // Find the first non-whitespace character. @@ -86,7 +86,7 @@ function getFirstNonWhitespaceInParagraph( (index) => (index > pos.character && !inclusive) || (index >= pos.character && inclusive) || - currentLine !== pos.line + currentLine !== pos.line, ); if (newCharacter !== undefined) { diff --git a/src/textobject/textobject.ts b/src/textobject/textobject.ts index 7df0e03ef..316d2604c 100644 --- a/src/textobject/textobject.ts +++ b/src/textobject/textobject.ts @@ -26,7 +26,7 @@ export abstract class TextObject extends BaseMovement { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { const res = await this.execAction(position, vimState); // Since we need to handle leading spaces, we cannot use MoveWordBegin.execActionForOperator @@ -135,7 +135,7 @@ export class SelectABigWord extends TextObject { stop = position.getLineEnd(); } else if ( (nextWord.isEqual( - TextEditor.getFirstNonWhitespaceCharOnLine(vimState.document, nextWord.line) + TextEditor.getFirstNonWhitespaceCharOnLine(vimState.document, nextWord.line), ) || nextWord.isLineEnd()) && vimState.recordedState.count === 0 @@ -190,7 +190,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection { position: Position, vimState: VimState, firstIteration: boolean, - lastIteration: boolean + lastIteration: boolean, ): Promise { const blocks = [ new MoveAroundDoubleQuotes(), @@ -208,7 +208,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection { const cursorPos = new Position(position.line, position.character); const cursorStartPos = new Position( vimState.cursorStartPosition.line, - vimState.cursorStartPosition.character + vimState.cursorStartPosition.character, ); ranges.push(await block.execAction(cursorPos, vimState, firstIteration, lastIteration)); vimState.cursorStartPosition = cursorStartPos; @@ -223,7 +223,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection { for (const iMotion of ranges) { const currentSelectedRange = new Cursor( vimState.cursorStartPosition, - vimState.cursorStopPosition + vimState.cursorStopPosition, ); if (iMotion.failed) { continue; @@ -266,11 +266,11 @@ export class SelectAnExpandingBlock extends ExpandingSelection { // revert relevant state changes vimState.cursorStartPosition = new Position( smallestRange.start.line, - smallestRange.start.character + smallestRange.start.character, ); vimState.cursorStopPosition = new Position( smallestRange.stop.line, - smallestRange.stop.character + smallestRange.stop.character, ); vimState.recordedState.operatorPositionDiff = undefined; return { @@ -609,13 +609,13 @@ abstract class IndentObjectMatch extends TextObject { vimState.document, firstValidLineNumber, cursorIndent, - -1 + -1, ); let endLineNumber = IndentObjectMatch.findRangeStartOrEnd( vimState.document, firstValidLineNumber, cursorIndent, - 1 + 1, ); // Adjust the start line as needed. @@ -664,7 +664,7 @@ abstract class IndentObjectMatch extends TextObject { public override async execActionForOperator( position: Position, - vimState: VimState + vimState: VimState, ): Promise { return this.execAction(position, vimState); } @@ -689,7 +689,7 @@ abstract class IndentObjectMatch extends TextObject { document: TextDocument, startIndex: number, cursorIndent: number, - step: -1 | 1 + step: -1 | 1, ): number { let i = startIndex; let ret = startIndex; @@ -796,12 +796,12 @@ abstract class SelectArgument extends TextObject { SelectInnerArgument.findLeftArgumentBoundary( vimState.document, leftSearchStartPosition, - true + true, ) === undefined || SelectInnerArgument.findRightArgumentBoundary( vimState.document, rightSearchStartPosition, - true + true, ) === undefined ) { return failure; @@ -809,7 +809,7 @@ abstract class SelectArgument extends TextObject { const leftArgumentBoundary = SelectInnerArgument.findLeftArgumentBoundary( vimState.document, - leftSearchStartPosition + leftSearchStartPosition, ); if (leftArgumentBoundary === undefined) { return failure; @@ -817,7 +817,7 @@ abstract class SelectArgument extends TextObject { const rightArgumentBoundary = SelectInnerArgument.findRightArgumentBoundary( vimState.document, - rightSearchStartPosition + rightSearchStartPosition, ); if (rightArgumentBoundary === undefined) { return failure; @@ -828,10 +828,10 @@ abstract class SelectArgument extends TextObject { if (this.selectAround) { const isLeftOnOpening: boolean = SelectArgument.openingDelimiterCharacters().includes( - TextEditor.getCharAt(vimState.document, leftArgumentBoundary) + TextEditor.getCharAt(vimState.document, leftArgumentBoundary), ); const isRightOnClosing: boolean = SelectArgument.closingDelimiterCharacters().includes( - TextEditor.getCharAt(vimState.document, rightArgumentBoundary) + TextEditor.getCharAt(vimState.document, rightArgumentBoundary), ); // Edge-case: @@ -903,7 +903,7 @@ abstract class SelectArgument extends TextObject { private static findLeftArgumentBoundary( document: TextDocument, position: Position, - ignoreSeparators: boolean = false + ignoreSeparators: boolean = false, ): Position | undefined { let delimiterPosition: Position | undefined; let walkingPosition = position; @@ -944,7 +944,7 @@ abstract class SelectArgument extends TextObject { private static findRightArgumentBoundary( document: TextDocument, position: Position, - ignoreSeparators: boolean = false + ignoreSeparators: boolean = false, ): Position | undefined { let delimiterPosition: Position | undefined; let walkingPosition = position; diff --git a/src/textobject/word.ts b/src/textobject/word.ts index 8f6a521b5..a79912776 100644 --- a/src/textobject/word.ts +++ b/src/textobject/word.ts @@ -36,7 +36,7 @@ function regexForWordType(wordType: WordType): RegExp { export function getWordLeftInText( text: string, pos: number, - wordType: WordType + wordType: WordType, ): number | undefined { return getWordLeftOnLine(text, pos, wordType); } @@ -44,7 +44,7 @@ export function getWordLeftInText( export function getWordRightInText( text: string, pos: number, - wordType: WordType + wordType: WordType, ): number | undefined { return getAllPositions(text, regexForWordType(wordType)).find((index) => index > pos); } @@ -53,7 +53,7 @@ export function prevWordStart( document: TextDocument, pos: Position, wordType: WordType, - inclusive: boolean = false + inclusive: boolean = false, ): Position { for (let currentLine = pos.line; currentLine >= 0; currentLine--) { const newCharacter = getWordLeftOnLine( @@ -61,7 +61,7 @@ export function prevWordStart( pos.character, wordType, currentLine !== pos.line, - inclusive + inclusive, ); if (newCharacter !== undefined) { @@ -77,7 +77,7 @@ function getWordLeftOnLine( pos: number, wordType: WordType, forceFirst: boolean = false, - inclusive: boolean = false + inclusive: boolean = false, ): number | undefined { return getAllPositions(text, regexForWordType(wordType)) .reverse() @@ -88,18 +88,18 @@ export function nextWordStart( document: TextDocument, pos: Position, wordType: WordType, - inclusive: boolean = false + inclusive: boolean = false, ): Position { for (let currentLine = pos.line; currentLine < document.lineCount; currentLine++) { const positions = getAllPositions( document.lineAt(currentLine).text, - regexForWordType(wordType) + regexForWordType(wordType), ); const newCharacter = positions.find( (index) => (index > pos.character && !inclusive) || (index >= pos.character && inclusive) || - currentLine !== pos.line + currentLine !== pos.line, ); if (newCharacter !== undefined) { @@ -114,18 +114,18 @@ export function nextWordEnd( document: TextDocument, pos: Position, wordType: WordType, - inclusive: boolean = false + inclusive: boolean = false, ): Position { for (let currentLine = pos.line; currentLine < document.lineCount; currentLine++) { const positions = getAllEndPositions( document.lineAt(currentLine).text, - regexForWordType(wordType) + regexForWordType(wordType), ); const newCharacter = positions.find( (index) => (index > pos.character && !inclusive) || (index >= pos.character && inclusive) || - currentLine !== pos.line + currentLine !== pos.line, ); if (newCharacter !== undefined) { @@ -140,7 +140,7 @@ export function prevWordEnd(document: TextDocument, pos: Position, wordType: Wor for (let currentLine = pos.line; currentLine > -1; currentLine--) { let positions = getAllEndPositions( document.lineAt(currentLine).text, - regexForWordType(wordType) + regexForWordType(wordType), ); // if one line is empty, use the 0 position as the default value if (positions.length === 0) { diff --git a/src/transformations/execute.ts b/src/transformations/execute.ts index 5c6fe9eb4..5829637d0 100644 --- a/src/transformations/execute.ts +++ b/src/transformations/execute.ts @@ -33,7 +33,7 @@ export interface IModeHandler { export async function executeTransformations( modeHandler: IModeHandler, - transformations: Transformation[] + transformations: Transformation[], ) { if (transformations.length === 0) { return; @@ -42,14 +42,14 @@ export async function executeTransformations( const vimState = modeHandler.vimState; const textTransformations: TextTransformations[] = transformations.filter((x) => - isTextTransformation(x) + isTextTransformation(x), ) as any; const multicursorTextTransformations: InsertTextVSCodeTransformation[] = transformations.filter( - (x) => isMultiCursorTextTransformation(x) + (x) => isMultiCursorTextTransformation(x), ) as any; const otherTransformations = transformations.filter( - (x) => !isTextTransformation(x) && !isMultiCursorTextTransformation(x) + (x) => !isTextTransformation(x) && !isMultiCursorTextTransformation(x), ); const accumulatedPositionDifferences: { [key: number]: PositionDiff[] } = {}; @@ -186,7 +186,7 @@ export async function executeTransformations( vimState.recordedState = new RecordedState(); if (transformation.register === ':') { await new ExCommandLine(recordedMacro.commandString, vimState.currentMode).run( - vimState + vimState, ); } else if (transformation.replay === 'contentChange') { await modeHandler.runMacro(recordedMacro); @@ -207,7 +207,7 @@ export async function executeTransformations( await executeTransformations( modeHandler, - vimState.recordedState.transformer.transformations + vimState.recordedState.transformer.transformations, ); globalState.lastInvokedMacro = recordedMacro; @@ -274,9 +274,9 @@ export async function executeTransformations( (cursor, diff) => new Cursor( cursor.start.add(vimState.document, diff), - cursor.stop.add(vimState.document, diff) + cursor.stop.add(vimState.document, diff), ), - Cursor.FromVSCodeSelection(sel) + Cursor.FromVSCodeSelection(sel), ); }); diff --git a/src/transformations/transformations.ts b/src/transformations/transformations.ts index 0ca00077c..54da8bb8b 100644 --- a/src/transformations/transformations.ts +++ b/src/transformations/transformations.ts @@ -234,7 +234,7 @@ const getRangeFromTextTransformation = (transformation: TextTransformations): Ra case 'insertText': return new Range( transformation.position, - transformation.position.advancePositionByText(transformation.text) + transformation.position.advancePositionByText(transformation.text), ); case 'replaceText': // TODO: Do we need to do the same sort of thing here as for insertText? @@ -249,7 +249,7 @@ const getRangeFromTextTransformation = (transformation: TextTransformations): Ra }; export function overlappingTransformations( - transformations: TextTransformations[] + transformations: TextTransformations[], ): [TextTransformations, TextTransformations] | undefined { for (let i = 0; i < transformations.length; i++) { for (let j = i + 1; j < transformations.length; j++) { diff --git a/src/util/child_process.ts b/src/util/child_process.ts index affbaaba9..e95dbb9f5 100644 --- a/src/util/child_process.ts +++ b/src/util/child_process.ts @@ -3,7 +3,7 @@ import { promisify } from 'util'; export function exec( command: string, - options?: child_process.ExecOptions + options?: child_process.ExecOptions, ): child_process.PromiseWithChild<{ stdout: string | Buffer; stderr: string | Buffer }> { return promisify(child_process.exec)(command, options); } diff --git a/src/util/decorationUtils.ts b/src/util/decorationUtils.ts index 3990d5109..bb524feab 100644 --- a/src/util/decorationUtils.ts +++ b/src/util/decorationUtils.ts @@ -46,7 +46,7 @@ export function ensureVisible(range: Range): DecorationOptions { export function formatDecorationText( text: string, tabsize: number, - newlineReplacement: string | ((substring: string, ...args: any[]) => string) = '\u23ce' // "⏎" RETURN SYMBOL + newlineReplacement: string | ((substring: string, ...args: any[]) => string) = '\u23ce', // "⏎" RETURN SYMBOL ) { // surround with zero-width space to prevent trimming return `\u200b${text @@ -62,7 +62,7 @@ export function formatDecorationText( */ export function getDecorationsForSearchMatchRanges( ranges: Range[], - currentMatchIndex?: number + currentMatchIndex?: number, ): SearchDecorations { const searchHighlight: DecorationOptions[] = []; const searchMatch: DecorationOptions[] = []; diff --git a/src/util/path.ts b/src/util/path.ts index f8ec10a2c..dccb18dcb 100644 --- a/src/util/path.ts +++ b/src/util/path.ts @@ -109,7 +109,7 @@ interface PathDetails { export function getPathDetails( partialPath: string, currentUri: vscode.Uri, - isRemote: boolean + isRemote: boolean, ): PathDetails { let isWindows: boolean; if (currentUri.scheme === 'untitled') { @@ -150,7 +150,7 @@ export function getPathDetails( // path will return /home/user for example even 'vscode-remote' is used on windows // as we relied of our isWindows detection separatePath(isWindows ? currentUri.fsPath : currentUri.path, p.sep)[0], - dirName + dirName, ); } @@ -179,7 +179,7 @@ export function resolveUri( absolutePath: string, sep: string, currentUri: vscode.Uri, - isRemote: boolean + isRemote: boolean, ) { const isWindows = sep === path.win32.sep; if (isWindows && !/^(\\\\.+\\)|([a-zA-Z]:\\)/.test(absolutePath)) { @@ -221,7 +221,7 @@ export async function readDirectory( sep: string, currentUri: vscode.Uri, isRemote: boolean, - addCurrentAndUp: boolean + addCurrentAndUp: boolean, ) { try { const directoryUri = resolveUri(absolutePath, sep, currentUri, isRemote); diff --git a/src/util/statusBarTextUtils.ts b/src/util/statusBarTextUtils.ts index 1cee03d05..305d7cad1 100644 --- a/src/util/statusBarTextUtils.ts +++ b/src/util/statusBarTextUtils.ts @@ -63,7 +63,7 @@ export function reportFileInfo(position: Position, vimState: VimState) { vimState, `"${fileName}"${modified} ${doc.lineCount} line${ doc.lineCount > 1 ? 's' : '' - } --${progress}%--` + } --${progress}%--`, ); } } diff --git a/src/vimscript/exCommandParser.ts b/src/vimscript/exCommandParser.ts index 886d634bb..11c979134 100644 --- a/src/vimscript/exCommandParser.ts +++ b/src/vimscript/exCommandParser.ts @@ -625,7 +625,7 @@ class UnimplementedCommand extends ExCommand { StatusBar.setText( vimState, `Command :${this.name} is not yet implemented (PRs are welcome!)`, - true + true, ); } @@ -642,7 +642,7 @@ export class NoOpCommand extends ExCommand { function nameParser( name: [string, string], - argParser: ArgParser | undefined + argParser: ArgParser | undefined, ): Parser> { argParser ??= all.result(new UnimplementedCommand(name[1] ? `${name[0]}[${name[1]}]` : name[0])); @@ -654,7 +654,7 @@ function nameParser( export const commandNameParser: Parser | undefined> = alt( ...[...builtinExCommands] .reverse() - .map(([name, argParser]) => nameParser(name, argParser?.skip(optWhitespace))) + .map(([name, argParser]) => nameParser(name, argParser?.skip(optWhitespace))), ); export const exCommandParser: Parser<{ lineRange: LineRange | undefined; command: ExCommand }> = @@ -665,14 +665,14 @@ export const exCommandParser: Parser<{ lineRange: LineRange | undefined; command LineRange.parser.fallback(undefined), optWhitespace, commandNameParser.fallback(undefined), - all - ) + all, + ), ) .map(([lineRange, whitespace, parseArgs, args]) => { if (parseArgs === undefined) { throw VimError.fromCode( ErrorCode.NotAnEditorCommand, - `${lineRange?.toString() ?? ''}${whitespace}${args}` + `${lineRange?.toString() ?? ''}${whitespace}${args}`, ); } const result = seq(parseArgs, optWhitespace.then(all)).parse(args); diff --git a/src/vimscript/expression.ts b/src/vimscript/expression.ts index 83ac318ee..06075bfc2 100644 --- a/src/vimscript/expression.ts +++ b/src/vimscript/expression.ts @@ -22,5 +22,5 @@ const escapedParser = string('\\') export const keystrokesExpressionParser: Parser = alt( escapedParser, specialCharacterParser, - noneOf('"') + noneOf('"'), ).many(); diff --git a/src/vimscript/lineRange.ts b/src/vimscript/lineRange.ts index 4af25c79e..971620196 100644 --- a/src/vimscript/lineRange.ts +++ b/src/vimscript/lineRange.ts @@ -92,7 +92,7 @@ const lineSpecifierParser: Parser = alt( }), string('\\/').result({ type: 'last_search_pattern_next' }), string('\\?').result({ type: 'last_search_pattern_prev' }), - string('\\&').result({ type: 'last_substitute_pattern_next' }) + string('\\&').result({ type: 'last_substitute_pattern_next' }), ); const offsetParser: Parser = alt( @@ -100,7 +100,7 @@ const offsetParser: Parser = alt( string('-') .then(numberParser.fallback(1)) .map((num) => -num), - numberParser + numberParser, ) .skip(optWhitespace) .atLeast(1) @@ -117,7 +117,7 @@ export class Address { public static parser: Parser
= alt( seq(lineSpecifierParser.skip(optWhitespace), offsetParser.fallback(0)), - seq(succeed({ type: 'current_line' as const }), offsetParser) + seq(succeed({ type: 'current_line' as const }), offsetParser), ).map(([specifier, offset]) => { return new Address(specifier, offset); }); @@ -155,13 +155,13 @@ export class Address { case 'pattern_next': const m = this.specifier.pattern.nextMatch( vimState.document, - vimState.cursorStopPosition + vimState.cursorStopPosition, ); if (m === undefined) { // TODO: throw proper errors for nowrapscan throw VimError.fromCode( ErrorCode.PatternNotFound, - this.specifier.pattern.patternString + this.specifier.pattern.patternString, ); } else { return m.start.line; @@ -175,13 +175,13 @@ export class Address { const nextMatch = globalState.searchState.getNextSearchMatchPosition( vimState, vimState.cursorStopPosition, - SearchDirection.Forward + SearchDirection.Forward, ); if (nextMatch === undefined) { // TODO: throw proper errors for nowrapscan throw VimError.fromCode( ErrorCode.PatternNotFound, - globalState.searchState.searchString + globalState.searchState.searchString, ); } return nextMatch.pos.line; @@ -192,13 +192,13 @@ export class Address { const prevMatch = globalState.searchState.getNextSearchMatchPosition( vimState, vimState.cursorStopPosition, - SearchDirection.Backward + SearchDirection.Backward, ); if (prevMatch === undefined) { // TODO: throw proper errors for nowrapscan throw VimError.fromCode( ErrorCode.PatternNotFound, - globalState.searchState.searchString + globalState.searchState.searchString, ); } return prevMatch.pos.line; @@ -211,12 +211,12 @@ export class Address { SearchDirection.Forward, vimState.cursorStopPosition, globalState.substituteState.searchPattern.patternString, - {} + {}, ) : undefined; const match = searchState?.getNextSearchMatchPosition( vimState, - vimState.cursorStopPosition + vimState.cursorStopPosition, ); if (match === undefined) { // TODO: throw proper errors for nowrapscan @@ -283,8 +283,8 @@ export class LineRange { Address.parser.skip(optWhitespace), seq( alt(string(','), string(';')).skip(optWhitespace), - Address.parser.fallback(undefined) - ).fallback(undefined) + Address.parser.fallback(undefined), + ).fallback(undefined), ).map(([start, sepEnd]) => { if (sepEnd) { const [sep, end] = sepEnd; @@ -295,11 +295,11 @@ export class LineRange { seq( // without the start line alt(string(','), string(';')).skip(optWhitespace), - Address.parser.fallback(undefined) + Address.parser.fallback(undefined), ).map((sepEnd) => { const [sep, end] = sepEnd; return new LineRange(new Address({ type: 'current_line' }), sep, end); - }) + }), ); public resolve(vimState: VimState): { start: number; end: number } { diff --git a/src/vimscript/parserUtils.ts b/src/vimscript/parserUtils.ts index b95bac7fa..9dcfc6a33 100644 --- a/src/vimscript/parserUtils.ts +++ b/src/vimscript/parserUtils.ts @@ -29,9 +29,9 @@ export const fileNameParser: Parser = alt( // TODO: anything else that needs escaping? return `\\${escaped}`; } - }) + }), ), - regexp(/\S/) + regexp(/\S/), ) .atLeast(1) .map((chars) => chars.join('')); @@ -50,10 +50,10 @@ export const fileOptParser: Parser = string('++') alt(string('bin'), string('binary')).result('bin'), alt(string('nobin'), string('nobinary')).result('nobin'), string('bad'), - string('edit') + string('edit'), ), - string('=').then(regexp(/\S+/)).fallback(undefined) - ) + string('=').then(regexp(/\S+/)).fallback(undefined), + ), ) .sepBy(whitespace) .desc('[++opt]'); @@ -80,8 +80,8 @@ export const fileCmdParser: Parser = string('+') // TODO: Ex command // lazy(() => exCommandParser), // Last line - succeed({ type: 'last_line' }) - ) + succeed({ type: 'last_line' }), + ), ) .fallback(undefined) .desc('[+cmd]'); diff --git a/src/vimscript/pattern.ts b/src/vimscript/pattern.ts index 87e20f75a..b0a6e0645 100644 --- a/src/vimscript/pattern.ts +++ b/src/vimscript/pattern.ts @@ -15,7 +15,7 @@ export function searchStringParser(args: { }> { return seq( Pattern.parser(args), - lazy(() => SearchOffset.parser.fallback(undefined)) + lazy(() => SearchOffset.parser.fallback(undefined)), ).map(([pattern, offset]) => { return { pattern, offset }; }); @@ -75,7 +75,7 @@ export class Pattern { } | { lineRange: LineRange; - } + }, ): PatternMatch[] { if (this.emptyBranch) { // HACK: This pattern matches each character, but for purposes of perf when highlighting, merge them. @@ -109,7 +109,7 @@ export class Pattern { // TODO: This is not exactly how Vim implements in-selection search (\%V), see :help \%V for more info. const searchRange = new Range( vimState.lastVisualSelection.start, - vimState.lastVisualSelection.end + vimState.lastVisualSelection.end, ); haystack = vimState.document.getText(searchRange); searchOffset = vimState.document.offsetAt(vimState.lastVisualSelection.start); @@ -142,7 +142,7 @@ export class Pattern { const matchRange = new Range( vimState.document.positionAt(searchOffset + match.index), - vimState.document.positionAt(searchOffset + match.index + match[0].length) + vimState.document.positionAt(searchOffset + match.index + match[0].length), ); if ( !this.inSelection && @@ -231,12 +231,12 @@ export class Pattern { string('\\') .then(any.fallback(undefined)) .map((escaped) => '\\' + (escaped ?? '\\')), - noneOf(']') + noneOf(']'), ) .many() .wrap(string('['), string(']')) .map((result) => '[' + result.join('') + ']'), - noneOf(delimiter) + noneOf(delimiter), ).many(), string(delimiter).fallback(undefined), (leadingBar, atoms, delim) => { @@ -267,7 +267,7 @@ export class Pattern { closed: delim !== undefined, emptyBranch, }; - } + }, ).map(({ patternString, caseOverride, inSelection, closed, emptyBranch }) => { const ignoreCase = Pattern.getIgnoreCase(patternString, { caseOverride, @@ -279,14 +279,14 @@ export class Pattern { Pattern.compileRegex(patternString, ignoreCase), inSelection ?? false, closed, - emptyBranch + emptyBranch, ); }); } private static getIgnoreCase( patternString: string, - flags: { caseOverride?: boolean; ignoreSmartcase: boolean } + flags: { caseOverride?: boolean; ignoreSmartcase: boolean }, ): boolean { if (flags.caseOverride !== undefined) { return flags.caseOverride; @@ -302,7 +302,7 @@ export class Pattern { regex: RegExp, inSelection: boolean, closed: boolean, - emptyBranch: boolean + emptyBranch: boolean, ) { this.patternString = patternString; this.direction = direction; @@ -348,14 +348,14 @@ export class SearchOffset { new SearchOffset({ type, delta: sign === '-' ? -num : num, - }) + }), ), seq(searchOffsetTypeParser, oneOf('+-')).map( ([type, sign]) => new SearchOffset({ type, delta: sign === '-' ? -1 : 1, - }) + }), ), seq(searchOffsetTypeParser).map(([type]) => new SearchOffset({ type, delta: 0 })), string(';/') @@ -377,7 +377,7 @@ export class SearchOffset { pattern, offset, }); - }) + }), ); public constructor(data: SearchOffsetData) { diff --git a/test/cmd_line/bang.test.ts b/test/cmd_line/bang.test.ts index f19108259..6e5f89433 100644 --- a/test/cmd_line/bang.test.ts +++ b/test/cmd_line/bang.test.ts @@ -97,7 +97,7 @@ suite('bang (!) cmd_line', () => { test('! can read from both stdout and stderr', async () => { await modeHandler.handleMultipleKeyEvents( - ':.!echo "stdout" && >&2 echo "stderr"\n'.split('') + ':.!echo "stdout" && >&2 echo "stderr"\n'.split(''), ); assertEqualLines(['stdout', 'stderr']); }); diff --git a/test/cmd_line/breakpoints.test.ts b/test/cmd_line/breakpoints.test.ts index d7d7cd48e..76662b187 100644 --- a/test/cmd_line/breakpoints.test.ts +++ b/test/cmd_line/breakpoints.test.ts @@ -29,11 +29,11 @@ suite('Breakpoints command', () => { const breakpoint = vscode.debug.breakpoints[0] as vscode.SourceBreakpoint; assert.strictEqual( breakpoint.location.uri.fsPath, - modeHandler.vimState.editor.document.uri.fsPath + modeHandler.vimState.editor.document.uri.fsPath, ); assert.strictEqual( breakpoint.location.range.start.line, - modeHandler.vimState.cursorStartPosition.line + modeHandler.vimState.cursorStartPosition.line, ); }); @@ -48,11 +48,11 @@ suite('Breakpoints command', () => { test('test "here" is redundant', async () => { assert.deepStrictEqual( exCommandParser.tryParse(':breaka here'), - exCommandParser.tryParse(':breaka') + exCommandParser.tryParse(':breaka'), ); assert.deepStrictEqual( exCommandParser.tryParse(':breakd here'), - exCommandParser.tryParse(':breakd') + exCommandParser.tryParse(':breakd'), ); }); }); diff --git a/test/cmd_line/cursorLocation.test.ts b/test/cmd_line/cursorLocation.test.ts index fafc83d0c..f6b0c6171 100644 --- a/test/cmd_line/cursorLocation.test.ts +++ b/test/cmd_line/cursorLocation.test.ts @@ -35,7 +35,7 @@ suite('cursor location', () => { assert.strictEqual( statusBarAfterCursorMovement.trim(), ':tes|t', - 'Command Tab Completion Failed' + 'Command Tab Completion Failed', ); }); @@ -59,7 +59,7 @@ suite('cursor location', () => { assert.strictEqual( statusBarAfterCursorMovement.trim(), '/tes|t', - 'Command Tab Completion Failed' + 'Command Tab Completion Failed', ); }); }); diff --git a/test/cmd_line/only.test.ts b/test/cmd_line/only.test.ts index 7579985ad..7465aadd3 100644 --- a/test/cmd_line/only.test.ts +++ b/test/cmd_line/only.test.ts @@ -59,7 +59,7 @@ suite.skip(':only command', () => { assert.strictEqual( vscode.window.visibleTextEditors.length, 1, - 'Did not reduce to single editor' + 'Did not reduce to single editor', ); assert.strictEqual(await isPanelVisible(), false, 'Panel is still visible'); }); diff --git a/test/cmd_line/smile.test.ts b/test/cmd_line/smile.test.ts index 7d8bfd57f..62f7dd7b8 100644 --- a/test/cmd_line/smile.test.ts +++ b/test/cmd_line/smile.test.ts @@ -28,7 +28,7 @@ suite('Smile command', () => { assert.strictEqual( vscode.window.visibleTextEditors.length, 1, - ':smile did not create a new untitled file' + ':smile did not create a new untitled file', ); }); diff --git a/test/cmd_line/split.test.ts b/test/cmd_line/split.test.ts index d01145105..97d11be51 100644 --- a/test/cmd_line/split.test.ts +++ b/test/cmd_line/split.test.ts @@ -24,7 +24,7 @@ suite('Horizontal split', () => { assert.strictEqual( vscode.window.visibleTextEditors.length, 2, - 'Editor did not split in 1 sec' + 'Editor did not split in 1 sec', ); }); } diff --git a/test/cmd_line/substitute.test.ts b/test/cmd_line/substitute.test.ts index b7c065972..73ba6529e 100644 --- a/test/cmd_line/substitute.test.ts +++ b/test/cmd_line/substitute.test.ts @@ -5,7 +5,7 @@ import { newTest } from '../testSimplifier'; function sub( pattern: string, replace: string, - args?: { lineRange?: string; flags?: string; count?: number } + args?: { lineRange?: string; flags?: string; count?: number }, ): string { const lineRange = args?.lineRange ?? ''; const flags = args?.flags !== undefined ? `/${args.flags}` : ''; diff --git a/test/cmd_line/tab.test.ts b/test/cmd_line/tab.test.ts index f1d5b3f66..263703949 100644 --- a/test/cmd_line/tab.test.ts +++ b/test/cmd_line/tab.test.ts @@ -35,7 +35,7 @@ suite('cmd_line tab', () => { test('tabe with absolute path when not in workspace opens file', async () => { const filePath = await createRandomFile('', ''); await new ExCommandLine(`tabe ${filePath}`, modeHandler.vimState.currentMode).run( - modeHandler.vimState + modeHandler.vimState, ); const editor = vscode.window.activeTextEditor; @@ -48,7 +48,7 @@ suite('cmd_line tab', () => { assert.strictEqual( editor.document.fileName.toLowerCase(), filePath.toLowerCase(), - 'Opened wrong file' + 'Opened wrong file', ); } } @@ -57,19 +57,19 @@ suite('cmd_line tab', () => { test('tabe with current file path does nothing', async () => { const filePath = await createRandomFile('', ''); await new ExCommandLine(`tabe ${filePath}`, modeHandler.vimState.currentMode).run( - modeHandler.vimState + modeHandler.vimState, ); const beforeEditor = vscode.window.activeTextEditor; await new ExCommandLine(`tabe ${filePath}`, modeHandler.vimState.currentMode).run( - modeHandler.vimState + modeHandler.vimState, ); const afterEditor = vscode.window.activeTextEditor; assert.strictEqual( beforeEditor, afterEditor, - 'Active editor changed even though :tabe opened the same file' + 'Active editor changed even though :tabe opened the same file', ); }); }); diff --git a/test/cmd_line/tabCompletion.test.ts b/test/cmd_line/tabCompletion.test.ts index 0f7628383..af824889f 100644 --- a/test/cmd_line/tabCompletion.test.ts +++ b/test/cmd_line/tabCompletion.test.ts @@ -110,7 +110,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarAfterTab, `:e ${dirPath}${sep}|`, - 'Cannot complete with / at the end' + 'Cannot complete with / at the end', ); } finally { await vscode.workspace.fs.delete(vscode.Uri.file(dirPath), { recursive: true }); @@ -184,7 +184,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarAfterTab, ':edit|it', - 'Failed to complete content left of the cursor' + 'Failed to complete content left of the cursor', ); await modeHandler.handleKeyEvent(''); @@ -204,7 +204,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarAfterTab.trim(), `:e ${testFilePath}|`, - 'Cannot complete to .testfile' + 'Cannot complete to .testfile', ); // Second tab - resolve to .testfile // ./ and ../ because . is not explicitly typed in. @@ -221,7 +221,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarAfterTab, `:e ${dirPath}${sep}..${sep}|`, - 'Cannot complete to ../' + 'Cannot complete to ../', ); // Second tab - resolve to ./ await modeHandler.handleKeyEvent(''); @@ -291,7 +291,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarAfterTab.toLowerCase(), `:e ${filePath}|`.toLowerCase(), - 'Cannot complete path case-insensitive on windows' + 'Cannot complete path case-insensitive on windows', ); } else { await modeHandler.handleMultipleKeyEvents(cmd); @@ -302,7 +302,7 @@ suite('cmd_line tabComplete', () => { assert.strictEqual( statusBarBeforeTab, statusBarAfterTab, - 'Is case-insensitive on non-windows' + 'Is case-insensitive on non-windows', ); } } finally { diff --git a/test/cmd_line/vsplit.test.ts b/test/cmd_line/vsplit.test.ts index 6139b2a37..585652e33 100644 --- a/test/cmd_line/vsplit.test.ts +++ b/test/cmd_line/vsplit.test.ts @@ -24,7 +24,7 @@ suite('Vertical split', () => { assert.strictEqual( vscode.window.visibleTextEditors.length, 2, - 'Editor did not split in 1 sec' + 'Editor did not split in 1 sec', ); }); } diff --git a/test/completion/lineCompletion.test.ts b/test/completion/lineCompletion.test.ts index 4a72be294..0c540a425 100644 --- a/test/completion/lineCompletion.test.ts +++ b/test/completion/lineCompletion.test.ts @@ -40,7 +40,7 @@ suite('Provide line completions', () => { const expectedCompletions = ['a2', 'a1', 'a3', 'a4']; const topCompletions = getCompletionsForCurrentLine( vimState.cursorStopPosition, - vimState.document + vimState.document, )!.slice(0, expectedCompletions.length); assert.deepStrictEqual(topCompletions, expectedCompletions, 'Unexpected completions found'); @@ -56,7 +56,7 @@ suite('Provide line completions', () => { const expectedCompletions = ['a 2', 'a1', 'a3 ', 'a4']; const topCompletions = getCompletionsForCurrentLine( vimState.cursorStopPosition, - vimState.document + vimState.document, )!.slice(0, expectedCompletions.length); assert.deepStrictEqual(topCompletions, expectedCompletions, 'Unexpected completions found'); @@ -68,7 +68,7 @@ suite('Provide line completions', () => { const expectedCompletions = []; const completions = getCompletionsForCurrentLine( vimState.cursorStopPosition, - vimState.document + vimState.document, )!.slice(0, expectedCompletions.length); assert.strictEqual(completions.length, 0, 'Completions found, but none were expected'); diff --git a/test/configuration/remapper.test.ts b/test/configuration/remapper.test.ts index 426495406..ef77c0f1b 100644 --- a/test/configuration/remapper.test.ts +++ b/test/configuration/remapper.test.ts @@ -79,13 +79,13 @@ suite('Remapper', () => { public override findMatchingRemap( userDefinedRemappings: Map, - inputtedKeys: string[] + inputtedKeys: string[], ) { return super.findMatchingRemap(userDefinedRemappings, inputtedKeys); } public getRemappedKeySequenceLengthRange( - remappings: Map + remappings: Map, ): [number, number] { return TestRemapper.getRemappedKeysLengthRange(remappings); } @@ -209,7 +209,7 @@ suite('Remapper', () => { actual, `Expected remap for before=${testCase.before}. input=${testCase.input}. mode=${ Mode[testCase.mode] - }.` + }.`, ); assert.deepStrictEqual(actual.after, testCase.expectedAfter.split('')); } else { @@ -240,7 +240,7 @@ suite('Remapper', () => { edit.insert( vscode.window.activeTextEditor!.document.uri, new vscode.Position(0, 0), - expectedDocumentContent + expectedDocumentContent, ); await vscode.workspace.applyEdit(edit); @@ -303,7 +303,7 @@ suite('Remapper', () => { edit.insert( vscode.window.activeTextEditor!.document.uri, new vscode.Position(0, 0), - expectedDocumentContent + expectedDocumentContent, ); await vscode.workspace.applyEdit(edit); @@ -600,7 +600,7 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 0, - 'Cursor is not on the right position, should be at the start of line' + 'Cursor is not on the right position, should be at the start of line', ); // act and assert @@ -650,7 +650,7 @@ suite('Remapper', () => { const cursorCharacter = modeHandler.vimState.cursorStopPosition.character; p1Resolve({ line: currentLine, position: cursorCharacter }); }, timeout / 2); - } + }, ); const p2: Promise<{ line: string; position: number }> = new Promise( (p2Resolve, p2Reject) => { @@ -660,18 +660,18 @@ suite('Remapper', () => { const cursorCharacter = modeHandler.vimState.cursorStopPosition.character; p2Resolve({ line: currentLine, position: cursorCharacter }); }, timeout + timeoutOffset); - } + }, ); const p3: Promise<{ line: string; position: number }> = new Promise( async (p3Resolve, p3Reject) => { await modeHandler.handleMultipleKeyEvents(['w', 'w', 'w']); p3Resolve({ line: 'modeHandler.handleMultipleKeyEvents finished', position: -1 }); - } + }, ); await Promise.all([p1, p2, p3]).then((results) => { r2Resolve(results); }); - } + }, ); // Before the timeout finishes it shouldn't have changed anything yet, @@ -680,7 +680,7 @@ suite('Remapper', () => { assert.strictEqual( result2[0].position, 0, - 'Cursor is not on the right position, should be at the start of line' + 'Cursor is not on the right position, should be at the start of line', ); // After the timeout finishes (plus an offset to be sure it finished) @@ -690,7 +690,7 @@ suite('Remapper', () => { assert.strictEqual( result2[1].position, 2, - 'Cursor is not on the right position, should be at the end of line' + 'Cursor is not on the right position, should be at the end of line', ); // add new line @@ -699,12 +699,12 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 2, - 'Cursor is not on the right position, should be at the end of line' + 'Cursor is not on the right position, should be at the end of line', ); assert.strictEqual( modeHandler.vimState.cursorStopPosition.line, 1, - 'Cursor is not on the right position, should be on second line' + 'Cursor is not on the right position, should be on second line', ); // check that 'wwww' -> 'dd' doesn't wait for timeout @@ -719,12 +719,12 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 0, - 'Cursor is not on the right position, shoul be at the start of line' + 'Cursor is not on the right position, shoul be at the start of line', ); assert.strictEqual( modeHandler.vimState.cursorStopPosition.line, 0, - 'Cursor is not on the right position, should be on first line' + 'Cursor is not on the right position, should be on first line', ); // We check if the elapsed time is less than half the timeout instead of @@ -744,12 +744,12 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 2, - 'Cursor is not on the right position, should be at the end of line' + 'Cursor is not on the right position, should be at the end of line', ); assert.strictEqual( modeHandler.vimState.cursorStopPosition.line, 1, - 'Cursor is not on the right position, should be on second line' + 'Cursor is not on the right position, should be on second line', ); // check 'bb' -> 'dd' sending each 'b' one by one checking between them to see @@ -766,12 +766,12 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 2, - 'Cursor is not on the right position, should be at the end of line' + 'Cursor is not on the right position, should be at the end of line', ); assert.strictEqual( modeHandler.vimState.cursorStopPosition.line, 1, - 'Cursor is not on the right position, should be on second line' + 'Cursor is not on the right position, should be on second line', ); // wait for 500 miliseconds (half of timeout) to simulate the time the user takes @@ -794,12 +794,12 @@ suite('Remapper', () => { assert.strictEqual( modeHandler.vimState.cursorStopPosition.character, 0, - 'Cursor is not on the right position, shoul be at the start of line' + 'Cursor is not on the right position, shoul be at the start of line', ); assert.strictEqual( modeHandler.vimState.cursorStopPosition.line, 0, - 'Cursor is not on the right position, should be on first line' + 'Cursor is not on the right position, should be on first line', ); // We check if the elapsedTime is less than the timeout minus an offset just diff --git a/test/configuration/validators/remappingValidator.test.ts b/test/configuration/validators/remappingValidator.test.ts index a7a991299..1a5a3d2e5 100644 --- a/test/configuration/validators/remappingValidator.test.ts +++ b/test/configuration/validators/remappingValidator.test.ts @@ -62,7 +62,7 @@ suite('Remapping Validator', () => { assert.strictEqual( configuration.insertModeKeyBindingsMap.get('jj'), - configuration.insertModeKeyBindings[0] + configuration.insertModeKeyBindings[0], ); }); diff --git a/test/configuration/vimrcKeyRemappingBuilder.test.ts b/test/configuration/vimrcKeyRemappingBuilder.test.ts index be4f5e410..6a3e913cb 100644 --- a/test/configuration/vimrcKeyRemappingBuilder.test.ts +++ b/test/configuration/vimrcKeyRemappingBuilder.test.ts @@ -152,7 +152,7 @@ suite('VimrcKeyRemappingBuilder', () => { for (const testCase of testCases) { const vimrcKeyRemapping = await vimrcKeyRemappingBuilder.build( testCase.vimrcLine, - vscodeCommands + vscodeCommands, ); if (testCase.expectNull) { @@ -361,7 +361,7 @@ suite('VimrcKeyRemappingBuilder', () => { for (const testCase of testCases) { const vimrcKeyRemapping = await vimrcKeyRemappingBuilder.buildClearMapping( - testCase.vimrcLine + testCase.vimrcLine, ); if (testCase.expectNull) { diff --git a/test/extension.test.ts b/test/extension.test.ts index fb8109b6b..934e2af21 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -16,7 +16,7 @@ suite('package.json', () => { const found = registeredCommands.includes(keybinding.command); assert.ok( found, - 'Missing handler for key=' + keybinding.key + '. Expected handler=' + keybinding.command + 'Missing handler for key=' + keybinding.key + '. Expected handler=' + keybinding.command, ); } }); diff --git a/test/historyTracker.test.ts b/test/historyTracker.test.ts index 86c012a42..5ac5c2e20 100644 --- a/test/historyTracker.test.ts +++ b/test/historyTracker.test.ts @@ -181,7 +181,7 @@ class TextEditorStub implements vscode.TextEditor { constructor() {} async edit( callback: (editBuilder: vscode.TextEditorEdit) => void, - options?: { undoStopBefore: boolean; undoStopAfter: boolean } + options?: { undoStopBefore: boolean; undoStopAfter: boolean }, ) { return true; } @@ -192,13 +192,13 @@ class TextEditorStub implements vscode.TextEditor { | vscode.Range | ReadonlyArray | ReadonlyArray, - options?: { undoStopBefore: boolean; undoStopAfter: boolean } + options?: { undoStopBefore: boolean; undoStopAfter: boolean }, ) { return true; } setDecorations( decorationType: vscode.TextEditorDecorationType, - rangesOrOptions: vscode.Range[] | vscode.DecorationOptions[] + rangesOrOptions: vscode.Range[] | vscode.DecorationOptions[], ) {} revealRange(range: vscode.Range, revealType?: vscode.TextEditorRevealType) {} show(column?: vscode.ViewColumn) {} diff --git a/test/jumpTracker.test.ts b/test/jumpTracker.test.ts index a98a5d490..ac9abc544 100644 --- a/test/jumpTracker.test.ts +++ b/test/jumpTracker.test.ts @@ -24,7 +24,7 @@ suite('Record and navigate jumps', () => { title: `Can track jumps for keys: ${options.keysPressed.replace(/\n/g, '')}`, ...options, }, - process.platform === 'win32' + process.platform === 'win32', ); }; @@ -52,12 +52,12 @@ suite('Record and navigate jumps', () => { assert.deepStrictEqual( jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3'], - 'Unexpected jumps found' + 'Unexpected jumps found', ); assert.strictEqual( jumpTracker.currentJump.fileName, 'file1', - 'Unexpected current jump found' + 'Unexpected current jump found', ); assert.strictEqual(jumpTracker.currentJumpNumber, 0, 'Unexpected current jump number found'); }); @@ -81,12 +81,12 @@ suite('Record and navigate jumps', () => { assert.deepStrictEqual( jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3', 'file4'], - 'Unexpected jumps found' + 'Unexpected jumps found', ); assert.strictEqual( jumpTracker.currentJump.fileName, 'file2', - 'Unexpected current jump found' + 'Unexpected current jump found', ); assert.strictEqual(jumpTracker.currentJumpNumber, 1, 'Unexpected current jump number found'); }); @@ -103,7 +103,7 @@ suite('Record and navigate jumps', () => { assert.deepStrictEqual( jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3', 'file2'], - 'Unexpected jumps found' + 'Unexpected jumps found', ); assert.strictEqual(jumpTracker.currentJump, null, 'Unexpected current jump found'); }); @@ -119,7 +119,7 @@ suite('Record and navigate jumps', () => { assert.deepStrictEqual( jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3'], - 'Unexpected jumps found' + 'Unexpected jumps found', ); assert.strictEqual(jumpTracker.currentJump, null, 'Unexpected current jump found'); }); @@ -135,7 +135,7 @@ suite('Record and navigate jumps', () => { assert.deepStrictEqual( jumpTracker.jumps.map((j) => j.position.line), range(102).slice(2, 102), - "Jump tracker doesn't contain the expected jumps after removing old jumps" + "Jump tracker doesn't contain the expected jumps after removing old jumps", ); }); @@ -147,12 +147,12 @@ suite('Record and navigate jumps', () => { assert.strictEqual( jumpTracker.jumps.length, 1, - 'Jump tracker failed to record "from"-only jump' + 'Jump tracker failed to record "from"-only jump', ); assert.deepEqual( jumpTracker.jumps.map((j) => [j.position.line, j.position.character, j.fileName]), [[0, 0, 'Untitled']], - `Jump tracker doesn't contain expected jumps after recording "from"-only jump` + `Jump tracker doesn't contain expected jumps after recording "from"-only jump`, ); }); @@ -176,7 +176,7 @@ suite('Record and navigate jumps', () => { [5, 5, 'file1'], [6, 0, 'file1'], ], - `Jump tracker doesn't contain the expected jumps before handling deleted text` + `Jump tracker doesn't contain the expected jumps before handling deleted text`, ); // Note that this is just deleting lines 3 and 4. @@ -184,7 +184,7 @@ suite('Record and navigate jumps', () => { // kind of like Array.slice. jumpTracker.handleTextDeleted( { fileName: 'file1' }, - new vscode.Range(new vscode.Position(3, 0), new vscode.Position(5, 0)) + new vscode.Range(new vscode.Position(3, 0), new vscode.Position(5, 0)), ); // Vim doesn't delete jumps at the deleted line, it just shifts other lines down @@ -198,12 +198,12 @@ suite('Record and navigate jumps', () => { [3, 5, 'file1'], [4, 0, 'file1'], ], - `Jump tracker doesn't contain the expected jumps after deleting two lines` + `Jump tracker doesn't contain the expected jumps after deleting two lines`, ); jumpTracker.handleTextDeleted( { fileName: 'file1' }, - new vscode.Range(new vscode.Position(3, 0), new vscode.Position(4, 0)) + new vscode.Range(new vscode.Position(3, 0), new vscode.Position(4, 0)), ); // If that results in multiple jumps on a line, though the duplicate is deleted @@ -216,12 +216,12 @@ suite('Record and navigate jumps', () => { [0, 0, 'file1'], [3, 0, 'file1'], ], - `Jump tracker doesn't contain the expected jumps after deleting another line` + `Jump tracker doesn't contain the expected jumps after deleting another line`, ); jumpTracker.handleTextDeleted( { fileName: 'file1' }, - new vscode.Range(new vscode.Position(0, 0), new vscode.Position(3, 0)) + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(3, 0)), ); // If you delete lines such that jumps are past EOF, delete the jumps @@ -232,7 +232,7 @@ suite('Record and navigate jumps', () => { [5, 0, 'file2'], [0, 0, 'file1'], ], - `Jump tracker doesn't contain the expected jumps after deleting all lines in file` + `Jump tracker doesn't contain the expected jumps after deleting all lines in file`, ); }); }); diff --git a/test/mode/modeHandler.test.ts b/test/mode/modeHandler.test.ts index 2004080bf..6735d6c65 100644 --- a/test/mode/modeHandler.test.ts +++ b/test/mode/modeHandler.test.ts @@ -27,7 +27,7 @@ suite('ModeHandler', () => { assert.notStrictEqual(modeHandler1, undefined); assert.deepStrictEqual( new Set(ModeHandlerMap.entries()), - new Set([[document1.uri, modeHandler1]]) + new Set([[document1.uri, modeHandler1]]), ); } @@ -45,7 +45,7 @@ suite('ModeHandler', () => { new Set([ [document1.uri, modeHandler1], [document2.uri, modeHandler2], - ]) + ]), ); } diff --git a/test/mode/modeInsert.test.ts b/test/mode/modeInsert.test.ts index 397734bbe..9eb4db9f1 100644 --- a/test/mode/modeInsert.test.ts +++ b/test/mode/modeInsert.test.ts @@ -47,7 +47,7 @@ suite('Mode Insert', () => { assert.strictEqual( vscode.window.activeTextEditor!.selection.start.character, 4, - ' moved cursor position.' + ' moved cursor position.', ); }); @@ -221,7 +221,7 @@ suite('Mode Insert', () => { assert.strictEqual( vscode.window.activeTextEditor!.selection.start.character, 3, - ' moved cursor to correct position' + ' moved cursor to correct position', ); }); diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts index 03c2c62bf..db5bd694d 100755 --- a/test/mode/modeNormal.test.ts +++ b/test/mode/modeNormal.test.ts @@ -1794,7 +1794,7 @@ suite('Mode Normal', () => { '// because it is hard.', ], }, - process.platform === 'win32' + process.platform === 'win32', ); newTest({ @@ -1812,7 +1812,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|// abc def'], }, - process.platform === 'win32' + process.platform === 'win32', ); // TODO(#4844): this fails on Windows @@ -1823,7 +1823,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|/*', ' * abc def', ' */'], }, - process.platform === 'win32' + process.platform === 'win32', ); // TODO(#4844): this fails on Windows @@ -1834,7 +1834,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|/*', ' * abc def */'], }, - process.platform === 'win32' + process.platform === 'win32', ); // TODO(#4844): this fails on Windows @@ -1845,7 +1845,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|/* abc def', ' */'], }, - process.platform === 'win32' + process.platform === 'win32', ); newTest({ @@ -1870,7 +1870,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|/* abc */', '/* def */'], }, - process.platform === 'win32' + process.platform === 'win32', ); // TODO(#4844): this fails on Windows @@ -1881,7 +1881,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ['|/* abc', ' */', '/* def', ' */'], }, - process.platform === 'win32' + process.platform === 'win32', ); // TODO(#4844): this fails on Windows @@ -1892,7 +1892,7 @@ suite('Mode Normal', () => { keysPressed: 'gqG', end: ["|Good morning, how are you? I'm Dr. Worm. I'm interested in things."], }, - process.platform === 'win32' + process.platform === 'win32', ); newTest({ diff --git a/test/mode/modeVisual.test.ts b/test/mode/modeVisual.test.ts index 9a2a10749..0a1c9823f 100644 --- a/test/mode/modeVisual.test.ts +++ b/test/mode/modeVisual.test.ts @@ -1371,14 +1371,14 @@ suite('Mode Visual', () => { suite('replace text in characterwise visual-mode with characterwise register content', () => { test('gv selects the last pasted text (which is shorter than original)', async () => { await modeHandler.handleMultipleKeyEvents( - 'ireplace this\nwith me\nor with me longer than the target'.split('') + 'ireplace this\nwith me\nor with me longer than the target'.split(''), ); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - '2ggv$hy'.split('') // yank the second line + '2ggv$hy'.split(''), // yank the second line ); await modeHandler.handleMultipleKeyEvents( - 'ggv$hp'.split('') // replace the first line + 'ggv$hp'.split(''), // replace the first line ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); @@ -1395,14 +1395,14 @@ suite('Mode Visual', () => { test('gv selects the last pasted text (which is longer than original)', async () => { await modeHandler.handleMultipleKeyEvents( - 'ireplace this\nwith me\nor with me longer than the target'.split('') + 'ireplace this\nwith me\nor with me longer than the target'.split(''), ); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - 'v0y'.split('') // yank the last line + 'v0y'.split(''), // yank the last line ); await modeHandler.handleMultipleKeyEvents( - 'ggv$hp'.split('') // replace the first line + 'ggv$hp'.split(''), // replace the first line ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); @@ -1425,10 +1425,10 @@ suite('Mode Visual', () => { await modeHandler.handleMultipleKeyEvents('ireplace this\nfoo\nbar'.split('')); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - '2ggvjey'.split('') // yank 'foo\nbar' + '2ggvjey'.split(''), // yank 'foo\nbar' ); await modeHandler.handleMultipleKeyEvents( - 'ggvep'.split('') // replace 'replace' + 'ggvep'.split(''), // replace 'replace' ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); diff --git a/test/mode/modeVisualLine.test.ts b/test/mode/modeVisualLine.test.ts index 01de0c7c1..9bb0a15ed 100644 --- a/test/mode/modeVisualLine.test.ts +++ b/test/mode/modeVisualLine.test.ts @@ -370,14 +370,14 @@ suite('Mode Visual Line', () => { test('gv selects the last pasted text (which is shorter than original)', async () => { await modeHandler.handleMultipleKeyEvents( - 'ireplace this\nwith me\nor with me longer than the target'.split('') + 'ireplace this\nwith me\nor with me longer than the target'.split(''), ); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - '2ggyy'.split('') // yank the second line + '2ggyy'.split(''), // yank the second line ); await modeHandler.handleMultipleKeyEvents( - 'ggVp'.split('') // replace the first line + 'ggVp'.split(''), // replace the first line ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); @@ -394,14 +394,14 @@ suite('Mode Visual Line', () => { test('gv selects the last pasted text (which is longer than original)', async () => { await modeHandler.handleMultipleKeyEvents( - 'ireplace this\nwith me\nor with me longer than the target'.split('') + 'ireplace this\nwith me\nor with me longer than the target'.split(''), ); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - 'yy'.split('') // yank the last line + 'yy'.split(''), // yank the last line ); await modeHandler.handleMultipleKeyEvents( - 'ggVp'.split('') // replace the first line + 'ggVp'.split(''), // replace the first line ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); @@ -424,10 +424,10 @@ suite('Mode Visual Line', () => { await modeHandler.handleMultipleKeyEvents('ireplace this\nfoo\nbar'.split('')); await modeHandler.handleMultipleKeyEvents(['']); await modeHandler.handleMultipleKeyEvents( - 'Vky'.split('') // yank 'foo\nbar\n' + 'Vky'.split(''), // yank 'foo\nbar\n' ); await modeHandler.handleMultipleKeyEvents( - 'ggVp'.split('') // replace the first line + 'ggVp'.split(''), // replace the first line ); await modeHandler.handleMultipleKeyEvents(['g', 'v']); diff --git a/test/mode/normalModeTests/motions.test.ts b/test/mode/normalModeTests/motions.test.ts index 6104a86a3..bafa039d2 100644 --- a/test/mode/normalModeTests/motions.test.ts +++ b/test/mode/normalModeTests/motions.test.ts @@ -968,7 +968,7 @@ suite('Motions in Normal Mode', () => { keysPressed: '10go', end: ['abc', 'def', 'g|hi'], }, - process.platform === 'win32' + process.platform === 'win32', ); }); diff --git a/test/multicursor.test.ts b/test/multicursor.test.ts index 93cab2b35..53e1b86f5 100644 --- a/test/multicursor.test.ts +++ b/test/multicursor.test.ts @@ -62,7 +62,7 @@ suite('Multicursor', () => { test('vibd with multicursors deletes the content between brackets and keeps the cursors', async () => { await modeHandler.handleMultipleKeyEvents( - 'i[(foo) asd ]\n[(bar) asd ]\n[(foo) asd ]'.split('') + 'i[(foo) asd ]\n[(bar) asd ]\n[(foo) asd ]'.split(''), ); await modeHandler.handleMultipleKeyEvents(['', '0', 'l', 'l']); assertEqualLines(['[(foo) asd ]', '[(bar) asd ]', '[(foo) asd ]']); @@ -77,7 +77,7 @@ suite('Multicursor', () => { test('vi[d with multicursors deletes the content between brackets and keeps the cursors', async () => { await modeHandler.handleMultipleKeyEvents( - 'i[(foo) asd ]\n[(bar) asd ]\n[(foo) asd ]'.split('') + 'i[(foo) asd ]\n[(bar) asd ]\n[(foo) asd ]'.split(''), ); await modeHandler.handleMultipleKeyEvents(['', '0', 'l', 'l']); assertEqualLines(['[(foo) asd ]', '[(bar) asd ]', '[(foo) asd ]']); @@ -92,7 +92,7 @@ suite('Multicursor', () => { test('vitd with multicursors deletes the content between tags and keeps the cursors', async () => { await modeHandler.handleMultipleKeyEvents( - 'i
foo bar
asd\n
foo asd
'.split('') + 'i
foo bar
asd\n
foo asd
'.split(''), ); await modeHandler.handleMultipleKeyEvents(['', 'k', '0', 'W']); assertEqualLines(['
foo bar
asd', '
foo asd
']); diff --git a/test/register/register.test.ts b/test/register/register.test.ts index 791481587..5c70f770b 100644 --- a/test/register/register.test.ts +++ b/test/register/register.test.ts @@ -164,7 +164,7 @@ suite('register', () => { test('Search register (/) is set by forward search', async () => { await modeHandler.handleMultipleKeyEvents( - 'iWake up early in Karakatu, Alaska'.split('').concat(['', '0']) + 'iWake up early in Karakatu, Alaska'.split('').concat(['', '0']), ); // Register changed by forward search @@ -182,7 +182,7 @@ suite('register', () => { test('Search register (/) is set by backward search', async () => { await modeHandler.handleMultipleKeyEvents( - 'iWake up early in Karakatu, Alaska'.split('').concat(['', '$']) + 'iWake up early in Karakatu, Alaska'.split('').concat(['', '$']), ); // Register changed by forward search @@ -200,7 +200,7 @@ suite('register', () => { test('Search register (/) is set by star search', async () => { await modeHandler.handleMultipleKeyEvents( - 'iWake up early in Karakatu, Alaska'.split('').concat(['', '0']) + 'iWake up early in Karakatu, Alaska'.split('').concat(['', '0']), ); await modeHandler.handleKeyEvent('*'); diff --git a/test/testSimplifier.ts b/test/testSimplifier.ts index 31ab0c41a..9e1a94835 100644 --- a/test/testSimplifier.ts +++ b/test/testSimplifier.ts @@ -21,10 +21,10 @@ import { TextEditor } from '../src/textEditor'; function newTestGeneric( testObj: T, testFunc: Mocha.TestFunction | Mocha.ExclusiveTestFunction | Mocha.PendingTestFunction, - innerTest: (testObj: T) => Promise + innerTest: (testObj: T) => Promise, ): void { const stack = ((s) => (s ? s.split('\n').splice(2, 1).join('\n') : 'no stack available :('))( - new Error().stack + new Error().stack, ); testFunc(testObj.title, async () => { @@ -214,9 +214,9 @@ async function testIt(testObj: ITestObject): Promise { await editor.edit((builder) => { builder.replace( new vscode.Range(new Position(0, 0), TextEditor.getDocumentEnd(editor.document)), - start.lines.join('\n') + start.lines.join('\n'), ); - }) + }), ); if (testObj.saveDocBeforeTest) { assert.ok(await editor.document.save()); @@ -252,14 +252,14 @@ async function testIt(testObj: ITestObject): Promise { assert.deepStrictEqual( { line: actualPosition.line, character: actualPosition.character }, { line: expectedPosition.line, character: expectedPosition.character }, - 'Cursor position is wrong.' + 'Cursor position is wrong.', ); if (testObj.endMode !== undefined) { assert.strictEqual( Mode[modeHandler.currentMode], Mode[testObj.endMode], - "Didn't enter correct mode." + "Didn't enter correct mode.", ); } @@ -277,7 +277,7 @@ async function testIt(testObj: ITestObject): Promise { assert.strictEqual( StatusBar.getText(), testObj.statusBar.replace('{FILENAME}', modeHandler.vimState.document.fileName), - 'Status bar text is wrong.' + 'Status bar text is wrong.', ); } @@ -287,7 +287,7 @@ async function testIt(testObj: ITestObject): Promise { assert.deepStrictEqual( globalState.jumpTracker.jumps.map((j) => end.lines[j.position.line] || ''), testObj.jumps.map((t) => t.replace('|', '')), - 'Incorrect jumps found' + 'Incorrect jumps found', ); const stripBar = (text: string | undefined) => (text ? text.replace('|', '') : text); @@ -300,7 +300,7 @@ async function testIt(testObj: ITestObject): Promise { assert.deepStrictEqual( actualJumpPosition, expectedJumpPosition, - 'Incorrect jump position found' + 'Incorrect jump position found', ); } @@ -445,7 +445,7 @@ async function testItWithRemaps(testObj: ITestWithRemapsObject): Promise { await ExCommandLine.loadHistory(new TestExtensionContext()); diff --git a/test/vimscript/exCommandParse.test.ts b/test/vimscript/exCommandParse.test.ts index 668dc76a3..91aa40414 100644 --- a/test/vimscript/exCommandParse.test.ts +++ b/test/vimscript/exCommandParse.test.ts @@ -85,25 +85,25 @@ suite('Ex command parsing', () => { exParseTest(':bd abc.txt', new BufferDeleteCommand({ bang: false, buffers: ['abc.txt'] })); exParseTest( ':bd abc.txt 5 blah.cc', - new BufferDeleteCommand({ bang: false, buffers: ['abc.txt', 5, 'blah.cc'] }) + new BufferDeleteCommand({ bang: false, buffers: ['abc.txt', 5, 'blah.cc'] }), ); exParseTest(':bd!', new BufferDeleteCommand({ bang: true, buffers: [] })); exParseTest(':bd! 2 5 3', new BufferDeleteCommand({ bang: true, buffers: [2, 5, 3] })); exParseTest(':bd! abc.txt', new BufferDeleteCommand({ bang: true, buffers: ['abc.txt'] })); exParseTest( ':bd! abc.txt 5 blah.cc', - new BufferDeleteCommand({ bang: true, buffers: ['abc.txt', 5, 'blah.cc'] }) + new BufferDeleteCommand({ bang: true, buffers: ['abc.txt', 5, 'blah.cc'] }), ); }); suite(':bn[ext]', () => { exParseTest( ':bn', - new TabCommand({ type: TabCommandType.Next, bang: false, cmd: undefined, count: undefined }) + new TabCommand({ type: TabCommandType.Next, bang: false, cmd: undefined, count: undefined }), ); exParseTest( ':bn!', - new TabCommand({ type: TabCommandType.Next, bang: true, cmd: undefined, count: undefined }) + new TabCommand({ type: TabCommandType.Next, bang: true, cmd: undefined, count: undefined }), ); exParseTest( ':bn 5', @@ -112,7 +112,7 @@ suite('Ex command parsing', () => { bang: false, cmd: undefined, count: 5, - }) + }), ); exParseTest( ':bn! 5', @@ -121,7 +121,7 @@ suite('Ex command parsing', () => { bang: true, cmd: undefined, count: 5, - }) + }), ); exParseTest( ':bn +20 5', @@ -130,7 +130,7 @@ suite('Ex command parsing', () => { bang: false, cmd: { type: 'line_number', line: 20 }, count: 5, - }) + }), ); exParseTest( ':bn! +20 5', @@ -139,7 +139,7 @@ suite('Ex command parsing', () => { bang: true, cmd: { type: 'line_number', line: 20 }, count: 5, - }) + }), ); }); @@ -180,7 +180,7 @@ suite('Ex command parsing', () => { new DeleteMarksCommand([ { start: 'A', end: 'K' }, { start: '2', end: '4' }, - ]) + ]), ); exParseFails(':delm'); // TODO: Should throw `E471: Argument required` @@ -198,7 +198,7 @@ suite('Ex command parsing', () => { exParseTest(':dig!', new DigraphsCommand({ bang: true, newDigraphs: [] })); exParseTest( ':dig e: 235', - new DigraphsCommand({ bang: false, newDigraphs: [['e', ':', 235]] }) + new DigraphsCommand({ bang: false, newDigraphs: [['e', ':', 235]] }), ); exParseTest( ':dig e: 235 a: 238', @@ -208,7 +208,7 @@ suite('Ex command parsing', () => { ['e', ':', 235], ['a', ':', 238], ], - }) + }), ); exParseFails(':dig e:'); @@ -217,29 +217,29 @@ suite('Ex command parsing', () => { suite(':e[dit]', () => { exParseTest( ':edit', - new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: undefined }) + new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: undefined }), ); exParseTest( ':edit!', - new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: undefined }) + new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: undefined }), ); exParseTest( ':edit abc.txt', - new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: 'abc.txt' }) + new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: 'abc.txt' }), ); exParseTest( ':edit! abc.txt', - new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: 'abc.txt' }) + new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: 'abc.txt' }), ); exParseTest( ':edit abc\\ 1.txt', - new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: 'abc 1.txt' }) + new FileCommand({ name: 'edit', bang: false, opt: [], cmd: undefined, file: 'abc 1.txt' }), ); exParseTest( ':edit! abc\\ 1.txt', - new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: 'abc 1.txt' }) + new FileCommand({ name: 'edit', bang: true, opt: [], cmd: undefined, file: 'abc 1.txt' }), ); // TODO: Test with [++opt] @@ -334,7 +334,7 @@ suite('Ex command parsing', () => { exParseTest(':r !ls', new ReadCommand({ opt: [], cmd: 'ls' })); exParseTest( ':r ++enc=foo abc.txt', - new ReadCommand({ opt: [['enc', 'foo']], file: 'abc.txt' }) + new ReadCommand({ opt: [['enc', 'foo']], file: 'abc.txt' }), ); exParseTest(':r ++enc=foo !ls', new ReadCommand({ opt: [['enc', 'foo']], cmd: 'ls' })); }); @@ -389,60 +389,60 @@ suite('Ex command parsing', () => { suite(':sor[t]', () => { exParseTest( ':sort', - new SortCommand({ reverse: false, ignoreCase: false, unique: false, numeric: false }) + new SortCommand({ reverse: false, ignoreCase: false, unique: false, numeric: false }), ); exParseTest( ':sort i', - new SortCommand({ reverse: false, ignoreCase: true, unique: false, numeric: false }) + new SortCommand({ reverse: false, ignoreCase: true, unique: false, numeric: false }), ); exParseTest( ':sort u', - new SortCommand({ reverse: false, ignoreCase: false, unique: true, numeric: false }) + new SortCommand({ reverse: false, ignoreCase: false, unique: true, numeric: false }), ); exParseTest( ':sort iu', - new SortCommand({ reverse: false, ignoreCase: true, unique: true, numeric: false }) + new SortCommand({ reverse: false, ignoreCase: true, unique: true, numeric: false }), ); exParseTest( ':sort ui', - new SortCommand({ reverse: false, ignoreCase: true, unique: true, numeric: false }) + new SortCommand({ reverse: false, ignoreCase: true, unique: true, numeric: false }), ); exParseTest( ':sort n', - new SortCommand({ reverse: false, ignoreCase: false, unique: false, numeric: true }) + new SortCommand({ reverse: false, ignoreCase: false, unique: false, numeric: true }), ); exParseTest( ':sort nu', - new SortCommand({ reverse: false, ignoreCase: false, unique: true, numeric: true }) + new SortCommand({ reverse: false, ignoreCase: false, unique: true, numeric: true }), ); exParseTest( ':sort!', - new SortCommand({ reverse: true, ignoreCase: false, unique: false, numeric: false }) + new SortCommand({ reverse: true, ignoreCase: false, unique: false, numeric: false }), ); exParseTest( ':sort! i', - new SortCommand({ reverse: true, ignoreCase: true, unique: false, numeric: false }) + new SortCommand({ reverse: true, ignoreCase: true, unique: false, numeric: false }), ); exParseTest( ':sort! u', - new SortCommand({ reverse: true, ignoreCase: false, unique: true, numeric: false }) + new SortCommand({ reverse: true, ignoreCase: false, unique: true, numeric: false }), ); exParseTest( ':sort! iu', - new SortCommand({ reverse: true, ignoreCase: true, unique: true, numeric: false }) + new SortCommand({ reverse: true, ignoreCase: true, unique: true, numeric: false }), ); exParseTest( ':sort! ui', - new SortCommand({ reverse: true, ignoreCase: true, unique: true, numeric: false }) + new SortCommand({ reverse: true, ignoreCase: true, unique: true, numeric: false }), ); exParseTest( ':sort! n', - new SortCommand({ reverse: true, ignoreCase: false, unique: false, numeric: true }) + new SortCommand({ reverse: true, ignoreCase: false, unique: false, numeric: true }), ); exParseTest( ':sort! nu', - new SortCommand({ reverse: true, ignoreCase: false, unique: true, numeric: true }) + new SortCommand({ reverse: true, ignoreCase: false, unique: true, numeric: true }), ); // TODO @@ -458,7 +458,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: { replaceAll: true }, count: undefined, - }) + }), ); exParseTest( ':s/a/b/g 3', @@ -467,7 +467,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: { replaceAll: true }, count: 3, - }) + }), ); exParseTest( ':s/a/b/g3', @@ -476,7 +476,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: { replaceAll: true }, count: 3, - }) + }), ); exParseTest( ':s/a/b/3', @@ -485,7 +485,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: {}, count: 3, - }) + }), ); // Can use weird delimiter exParseTest( @@ -495,7 +495,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: { replaceAll: true }, count: undefined, - }) + }), ); // Can escape delimiter exParseTest( @@ -505,7 +505,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: {}, count: undefined, - }) + }), ); // Can use pattern escapes exParseTest( @@ -515,7 +515,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: 'b' }]), flags: {}, count: undefined, - }) + }), ); // Can escape replacement exParseTest( @@ -525,7 +525,7 @@ suite('Ex command parsing', () => { replace: new ReplaceString([{ type: 'string', value: '\b' }]), flags: {}, count: undefined, - }) + }), ); // TODO @@ -534,31 +534,31 @@ suite('Ex command parsing', () => { suite(':tabm[ove]', () => { exParseTest( ':tabm', - new TabCommand({ type: TabCommandType.Move, count: undefined, direction: undefined }) + new TabCommand({ type: TabCommandType.Move, count: undefined, direction: undefined }), ); exParseTest( ':tabm 0', - new TabCommand({ type: TabCommandType.Move, count: 0, direction: undefined }) + new TabCommand({ type: TabCommandType.Move, count: 0, direction: undefined }), ); exParseTest( ':tabm 10', - new TabCommand({ type: TabCommandType.Move, count: 10, direction: undefined }) + new TabCommand({ type: TabCommandType.Move, count: 10, direction: undefined }), ); exParseTest( ':tabm +', - new TabCommand({ type: TabCommandType.Move, count: undefined, direction: 'right' }) + new TabCommand({ type: TabCommandType.Move, count: undefined, direction: 'right' }), ); exParseTest( ':tabm +10', - new TabCommand({ type: TabCommandType.Move, count: 10, direction: 'right' }) + new TabCommand({ type: TabCommandType.Move, count: 10, direction: 'right' }), ); exParseTest( ':tabm -', - new TabCommand({ type: TabCommandType.Move, count: undefined, direction: 'left' }) + new TabCommand({ type: TabCommandType.Move, count: undefined, direction: 'left' }), ); exParseTest( ':tabm -10', - new TabCommand({ type: TabCommandType.Move, count: 10, direction: 'left' }) + new TabCommand({ type: TabCommandType.Move, count: 10, direction: 'left' }), ); // TODO: these should throw E474; not clear that's the parser's job though @@ -576,11 +576,11 @@ suite('Ex command parsing', () => { suite(':tabo[nly]', () => { exParseTest( ':tabonly', - new TabCommand({ type: TabCommandType.Only, bang: false, count: undefined }) + new TabCommand({ type: TabCommandType.Only, bang: false, count: undefined }), ); exParseTest( ':tabonly!', - new TabCommand({ type: TabCommandType.Only, bang: true, count: undefined }) + new TabCommand({ type: TabCommandType.Only, bang: true, count: undefined }), ); exParseTest(':tabonly5', new TabCommand({ type: TabCommandType.Only, bang: false, count: 5 })); exParseTest(':tabonly!5', new TabCommand({ type: TabCommandType.Only, bang: true, count: 5 })); @@ -601,11 +601,11 @@ suite('Ex command parsing', () => { exParseTest( ':w ++bin', - new WriteCommand({ bang: false, opt: [['bin', undefined]], bgWrite: true }) + new WriteCommand({ bang: false, opt: [['bin', undefined]], bgWrite: true }), ); exParseTest( ':w ++enc=foo', - new WriteCommand({ bang: false, opt: [['enc', 'foo']], bgWrite: true }) + new WriteCommand({ bang: false, opt: [['enc', 'foo']], bgWrite: true }), ); exParseTest( ':w ++bin ++enc=foo', @@ -616,12 +616,12 @@ suite('Ex command parsing', () => { ['enc', 'foo'], ], bgWrite: true, - }) + }), ); exParseTest( ':w ++enc=foo blah.txt', - new WriteCommand({ bang: false, opt: [['enc', 'foo']], file: 'blah.txt', bgWrite: true }) + new WriteCommand({ bang: false, opt: [['enc', 'foo']], file: 'blah.txt', bgWrite: true }), ); exParseTest(':w !foo', new WriteCommand({ bang: false, opt: [], cmd: 'foo', bgWrite: true })); diff --git a/test/vimscript/lineRangeParse.test.ts b/test/vimscript/lineRangeParse.test.ts index bfafe5ede..b116ca660 100644 --- a/test/vimscript/lineRangeParse.test.ts +++ b/test/vimscript/lineRangeParse.test.ts @@ -26,8 +26,8 @@ suite('LineRange parsing', () => { new Address({ type: 'pattern_next', pattern: Pattern.parser({ direction: SearchDirection.Forward }).tryParse('abc'), - }) - ) + }), + ), ); parseTest( 'pattern_next (closing /)', @@ -39,8 +39,8 @@ suite('LineRange parsing', () => { direction: SearchDirection.Forward, delimiter: '/', }).tryParse('abc/'), - }) - ) + }), + ), ); parseTest( 'pattern_prev (no closing ?)', @@ -49,8 +49,8 @@ suite('LineRange parsing', () => { new Address({ type: 'pattern_prev', pattern: Pattern.parser({ direction: SearchDirection.Backward }).tryParse('abc'), - }) - ) + }), + ), ); parseTest( 'pattern_prev (closing ?)', @@ -62,23 +62,23 @@ suite('LineRange parsing', () => { direction: SearchDirection.Backward, delimiter: '?', }).tryParse('abc?'), - }) - ) + }), + ), ); parseTest( 'last_search_pattern_next', '\\/', - new LineRange(new Address({ type: 'last_search_pattern_next' })) + new LineRange(new Address({ type: 'last_search_pattern_next' })), ); parseTest( 'last_search_pattern_prev', '\\?', - new LineRange(new Address({ type: 'last_search_pattern_prev' })) + new LineRange(new Address({ type: 'last_search_pattern_prev' })), ); parseTest( 'last_substitute_pattern_next', '\\&', - new LineRange(new Address({ type: 'last_substitute_pattern_next' })) + new LineRange(new Address({ type: 'last_substitute_pattern_next' })), ); }); @@ -87,7 +87,7 @@ suite('LineRange parsing', () => { parseTest( 'Separator but no second address', `5${sep}`, - new LineRange(new Address({ type: 'number', num: 5 }), sep) + new LineRange(new Address({ type: 'number', num: 5 }), sep), ); parseTest( 'Separator but no first address', @@ -95,13 +95,13 @@ suite('LineRange parsing', () => { new LineRange( new Address({ type: 'current_line' }), sep, - new Address({ type: 'number', num: 5 }) - ) + new Address({ type: 'number', num: 5 }), + ), ); parseTest( 'Separator but no address at all', `${sep}`, - new LineRange(new Address({ type: 'current_line' }), sep) + new LineRange(new Address({ type: 'current_line' }), sep), ); parseTest( 'Two numbers', @@ -109,8 +109,8 @@ suite('LineRange parsing', () => { new LineRange( new Address({ type: 'number', num: 14 }), sep, - new Address({ type: 'number', num: 23 }) - ) + new Address({ type: 'number', num: 23 }), + ), ); parseTest( 'Two numbers (out of order)', @@ -118,8 +118,8 @@ suite('LineRange parsing', () => { new LineRange( new Address({ type: 'number', num: 123 }), sep, - new Address({ type: 'number', num: 6 }) - ) + new Address({ type: 'number', num: 6 }), + ), ); parseTest( 'Visual selection using marks', @@ -127,8 +127,8 @@ suite('LineRange parsing', () => { new LineRange( new Address({ type: 'mark', mark: '<' }), sep, - new Address({ type: 'mark', mark: '>' }) - ) + new Address({ type: 'mark', mark: '>' }), + ), ); }); @@ -139,8 +139,8 @@ suite('LineRange parsing', () => { new LineRange( new Address({ type: 'number', num: 1 }, 5), ',', - new Address({ type: 'number', num: 4 }, 11) - ) + new Address({ type: 'number', num: 4 }, 11), + ), ); }); } diff --git a/test/vimscript/lineRangeResolve.test.ts b/test/vimscript/lineRangeResolve.test.ts index 2bd9ed757..d5e3bca79 100644 --- a/test/vimscript/lineRangeResolve.test.ts +++ b/test/vimscript/lineRangeResolve.test.ts @@ -14,7 +14,7 @@ function resolveTest(input: ITestObject & { lineRanges: Record