From b6d75ca49ac2bd602f0c6391f699e448d7809f5d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2020 13:02:33 -0400 Subject: [PATCH] Update dependency prettier to v2 (#4661) All line endings are now unix-style (\n), and arrow functions always have parentheses around their parameters. --- .prettierrc | 3 +- extension.ts | 24 +- gulpfile.js | 26 +- package-lock.json | 6 +- package.json | 2 +- src/actions/base.ts | 2 +- src/actions/commands/actions.ts | 43 +-- src/actions/commands/commandLine.ts | 10 +- src/actions/commands/insert.ts | 19 +- src/actions/operator.ts | 2 +- src/actions/plugins/easymotion/easymotion.ts | 4 +- src/actions/plugins/surround.ts | 5 +- src/actions/textobject.ts | 2 +- src/cmd_line/commandLine.ts | 14 +- src/cmd_line/commands/digraph.ts | 2 +- src/cmd_line/commands/file.ts | 2 +- src/cmd_line/commands/marks.ts | 4 +- src/cmd_line/commands/quit.ts | 2 +- src/cmd_line/commands/register.ts | 6 +- src/cmd_line/commands/write.ts | 2 +- src/cmd_line/lexer.ts | 2 +- src/cmd_line/node.ts | 4 +- src/cmd_line/scanner.ts | 2 +- src/common/matching/tagMatcher.ts | 2 +- src/common/motion/position.ts | 24 +- src/configuration/configuration.ts | 6 +- src/configuration/iconfigurationValidator.ts | 4 +- src/configuration/remapper.ts | 8 +- .../validators/neovimValidator.ts | 2 +- .../validators/remappingValidator.ts | 2 +- src/configuration/vimrc.ts | 6 +- src/history/historyTracker.ts | 22 +- src/jumps/jumpTracker.ts | 6 +- src/mode/modeHandler.ts | 30 +- src/neovim/neovim.ts | 2 +- src/register/register.ts | 2 +- src/state/globalState.ts | 4 +- src/state/recordedState.ts | 6 +- src/state/searchState.ts | 7 +- src/taskQueue.ts | 9 +- src/textEditor.ts | 8 +- src/util/path.ts | 2 +- src/util/util.ts | 2 +- test/cmd_line/command.test.ts | 306 +++++++++--------- test/cmd_line/only.test.ts | 2 +- test/completion/lineCompletion.test.ts | 4 +- test/extension.test.ts | 4 +- test/historyTracker.test.ts | 4 +- test/jumpTracker.test.ts | 20 +- test/mode/modeHandlerMap.test.ts | 6 +- test/testSimplifier.ts | 15 +- test/testUtils.ts | 2 +- 52 files changed, 327 insertions(+), 378 deletions(-) diff --git a/.prettierrc b/.prettierrc index 789ac2e5d..5ac85e271 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,4 @@ { "printWidth": 100, - "singleQuote": true, - "trailingComma": "es5" + "singleQuote": true } diff --git a/extension.ts b/extension.ts index 672925d1e..6cef1592c 100644 --- a/extension.ts +++ b/extension.ts @@ -126,7 +126,7 @@ export async function activate(context: vscode.ExtensionContext) { false ); - registerEventListener(context, vscode.workspace.onDidChangeTextDocument, async event => { + registerEventListener(context, vscode.workspace.onDidChangeTextDocument, async (event) => { const textWasDeleted = (changeEvent: vscode.TextDocumentChangeEvent) => changeEvent.contentChanges.length === 1 && changeEvent.contentChanges[0].text === '' && @@ -169,8 +169,8 @@ export async function activate(context: vscode.ExtensionContext) { contentChangeHandler(Globals.mockModeHandler as ModeHandler); } else { ModeHandlerMap.getAll() - .filter(modeHandler => modeHandler.vimState.identity.fileName === event.document.fileName) - .forEach(modeHandler => { + .filter((modeHandler) => modeHandler.vimState.identity.fileName === event.document.fileName) + .forEach((modeHandler) => { contentChangeHandler(modeHandler); }); } @@ -185,7 +185,7 @@ export async function activate(context: vscode.ExtensionContext) { registerEventListener( context, vscode.workspace.onDidCloseTextDocument, - async closedDocument => { + async (closedDocument) => { const documents = vscode.workspace.textDocuments; // Delete modehandler once all tabs of this document have been closed @@ -213,7 +213,7 @@ export async function activate(context: vscode.ExtensionContext) { false ); - registerEventListener(context, vscode.workspace.onDidSaveTextDocument, async document => { + registerEventListener(context, vscode.workspace.onDidSaveTextDocument, async (document) => { if ( configuration.vimrc.enable && path.relative(document.fileName, configuration.vimrc.path) === '' @@ -314,7 +314,7 @@ export async function activate(context: vscode.ExtensionContext) { const compositionState = new CompositionState(); // Override VSCode commands - overrideCommand(context, 'type', async args => { + overrideCommand(context, 'type', async (args) => { taskQueue.enqueueTask(async () => { const mh = await getAndUpdateModeHandler(); @@ -326,7 +326,7 @@ export async function activate(context: vscode.ExtensionContext) { }); }); - overrideCommand(context, 'replacePreviousChar', async args => { + overrideCommand(context, 'replacePreviousChar', async (args) => { taskQueue.enqueueTask(async () => { const mh = await getAndUpdateModeHandler(); @@ -460,7 +460,7 @@ function overrideCommand( command: string, callback: (...args: any[]) => any ) { - const disposable = vscode.commands.registerCommand(command, async args => { + const disposable = vscode.commands.registerCommand(command, async (args) => { if (configuration.disableExtension) { return vscode.commands.executeCommand('default:' + command, args); } @@ -486,7 +486,7 @@ function registerCommand( command: string, callback: (...args: any[]) => any ) { - const disposable = vscode.commands.registerCommand(command, async args => { + const disposable = vscode.commands.registerCommand(command, async (args) => { if (!vscode.window.activeTextEditor) { return; } @@ -503,7 +503,7 @@ function registerEventListener( exitOnExtensionDisable = true, exitOnTests = false ) { - const disposable = event(async e => { + const disposable = event(async (e) => { if (exitOnExtensionDisable && configuration.disableExtension) { return; } @@ -527,8 +527,8 @@ async function handleKeyEvent(key: string): Promise { function handleContentChangedFromDisk(document: vscode.TextDocument): void { ModeHandlerMap.getAll() - .filter(modeHandler => modeHandler.vimState.identity.fileName === document.fileName) - .forEach(modeHandler => { + .filter((modeHandler) => modeHandler.vimState.identity.fileName === document.fileName) + .forEach((modeHandler) => { modeHandler.vimState.historyTracker.clear(); }); } diff --git a/gulpfile.js b/gulpfile.js index 326fc7bbd..d606bc487 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,7 +19,7 @@ const releaseOptions = { // prettier function runPrettier(command, done) { - exec(command, function(err, stdout) { + exec(command, function (err, stdout) { if (err) { return done(new PluginError('runPrettier', { message: err })); } @@ -30,7 +30,7 @@ function runPrettier(command, done) { var files = stdout .split(/\r?\n/) - .filter(f => { + .filter((f) => { return f.endsWith('.ts') || f.endsWith('.js') || f.endsWith('.md'); }) .join(' '); @@ -40,7 +40,7 @@ function runPrettier(command, done) { } const prettierPath = path.normalize('./node_modules/.bin/prettier'); - exec(`${prettierPath} --write ${files}`, function(err) { + exec(`${prettierPath} --write ${files}`, function (err) { if (err) { return done(new PluginError('runPrettier', { message: err })); } @@ -106,7 +106,7 @@ function createChangelog(done) { } ); - dockerRunCmd.on('exit', function(exitCode) { + dockerRunCmd.on('exit', function (exitCode) { done(exitCode); }); } @@ -133,7 +133,7 @@ function updateVersion(done) { }); } -gulp.task('tsc', function() { +gulp.task('tsc', function () { var isError = false; var tsProject = ts.createProject('tsconfig.json', { noEmitOnError: true }); @@ -153,7 +153,7 @@ gulp.task('tsc', function() { .pipe(gulp.dest('out')); }); -gulp.task('tslint', function() { +gulp.task('tslint', function () { const program = require('tslint').Linter.createProgram('./tsconfig.json'); return gulp .src(['**/*.ts', '!node_modules/**', '!typings/**']) @@ -166,25 +166,25 @@ gulp.task('tslint', function() { .pipe(tslint.report({ summarizeFailureOutput: true })); }); -gulp.task('prettier', function(done) { +gulp.task('prettier', function (done) { // files changed runPrettier('git diff --name-only HEAD', done); }); -gulp.task('forceprettier', function(done) { +gulp.task('forceprettier', function (done) { // files managed by git runPrettier('git ls-files', done); }); -gulp.task('commit-hash', function(done) { - git.revParse({ args: 'HEAD', quiet: true }, function(err, hash) { +gulp.task('commit-hash', function (done) { + git.revParse({ args: 'HEAD', quiet: true }, function (err, hash) { require('fs').writeFileSync('out/version', hash); done(); }); }); // test -gulp.task('test', function(done) { +gulp.task('test', function (done) { // the flag --grep takes js regex as a string and filters by test and test suite names var knownOptions = { string: 'grep', @@ -205,7 +205,7 @@ gulp.task('test', function(done) { } ); - dockerBuildCmd.on('exit', function(exitCode) { + dockerBuildCmd.on('exit', function (exitCode) { if (exitCode !== 0) { return done( new PluginError('test', { @@ -229,7 +229,7 @@ gulp.task('test', function(done) { stdio: 'inherit', }); - dockerRunCmd.on('exit', function(exitCode) { + dockerRunCmd.on('exit', function (exitCode) { done(exitCode); }); }); diff --git a/package-lock.json b/package-lock.json index 1da2af000..bb47c7d3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4684,9 +4684,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.2.tgz", + "integrity": "sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==", "dev": true }, "pretty-hrtime": { diff --git a/package.json b/package.json index af30fed2d..04ffeb812 100644 --- a/package.json +++ b/package.json @@ -970,7 +970,7 @@ "minimist": "1.2.5", "mocha": "7.1.1", "plugin-error": "1.0.1", - "prettier": "1.19.1", + "prettier": "2.0.2", "sinon": "9.0.1", "ts-loader": "6.2.2", "tslint": "6.1.0", diff --git a/src/actions/base.ts b/src/actions/base.ts index 548cd2100..37a90ade2 100644 --- a/src/actions/base.ts +++ b/src/actions/base.ts @@ -72,7 +72,7 @@ export class BaseAction { } const keys2D = BaseAction.is2DArray(this.keys) ? this.keys : [this.keys]; - const keysSlice = keys2D.map(x => x.slice(0, keysPressed.length)); + const keysSlice = keys2D.map((x) => x.slice(0, keysPressed.length)); if (!BaseAction.CompareKeypressSequence(keysSlice, keysPressed)) { return false; } diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 935df1315..32d3af2c0 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -214,7 +214,7 @@ export abstract class BaseCommand extends BaseAction { let resultingCursors: Range[] = []; const cursorsToIterateOver = vimState.cursors - .map(x => new Range(x.start, x.stop)) + .map((x) => new Range(x.start, x.stop)) .sort((a, b) => a.start.line > b.start.line || (a.start.line === b.start.line && a.start.character > b.start.character) @@ -861,7 +861,7 @@ class CommandOverrideCopy extends BaseCommand { if (vimState.currentMode === Mode.Visual) { text = vimState.cursors - .map(range => { + .map((range) => { const start = Position.EarlierOf(range.start, range.stop); const stop = Position.LaterOf(range.start, range.stop); return vimState.editor.document.getText(new vscode.Range(start, stop.getRight())); @@ -869,7 +869,7 @@ class CommandOverrideCopy extends BaseCommand { .join('\n'); } else if (vimState.currentMode === Mode.VisualLine) { text = vimState.cursors - .map(range => { + .map((range) => { return vimState.editor.document.getText( new vscode.Range( Position.EarlierOf(range.start.getLineBegin(), range.stop.getLineBegin()), @@ -884,7 +884,7 @@ class CommandOverrideCopy extends BaseCommand { } } else if (vimState.currentMode === Mode.Insert || vimState.currentMode === Mode.Normal) { text = vimState.editor.selections - .map(selection => { + .map((selection) => { return vimState.editor.document.getText(new vscode.Range(selection.start, selection.end)); }) .join('\n'); @@ -1257,7 +1257,7 @@ export class PutCommand extends BaseCommand { text = text .split('\n') - .map(line => { + .map((line) => { let currentIdentationWidth = TextEditor.getIndentationLevel(line); let newIndentationWidth = currentIdentationWidth - firstLineIdentationWidth + indentationWidth; @@ -1308,7 +1308,7 @@ export class PutCommand extends BaseCommand { vimState.currentMode === Mode.VisualLine && register.registerMode === RegisterMode.LineWise ) { - const numNewline = [...text].filter(c => c === '\n').length; + const numNewline = [...text].filter((c) => c === '\n').length; diff = PositionDiff.newBOLDiff(-numNewline - (noNextLine ? 0 : 1)); } else if (register.registerMode === RegisterMode.LineWise) { const check = text.match(/^\s*/); @@ -2061,7 +2061,7 @@ class CommandUndo extends BaseCommand { if (newPositions === undefined) { StatusBar.setText(vimState, 'Already at oldest change'); } else { - vimState.cursors = newPositions.map(x => new Range(x, x)); + vimState.cursors = newPositions.map((x) => new Range(x, x)); } vimState.alteredHistory = true; @@ -2083,7 +2083,7 @@ class CommandUndoOnLine extends BaseCommand { const newPositions = await vimState.historyTracker.goBackHistoryStepsOnLine(); if (newPositions !== undefined) { - vimState.cursors = newPositions.map(x => new Range(x, x)); + vimState.cursors = newPositions.map((x) => new Range(x, x)); } vimState.alteredHistory = true; @@ -2105,7 +2105,7 @@ class CommandRedo extends BaseCommand { if (newPositions === undefined) { StatusBar.setText(vimState, 'Already at newest change'); } else { - vimState.cursors = newPositions.map(x => new Range(x, x)); + vimState.cursors = newPositions.map((x) => new Range(x, x)); } vimState.alteredHistory = true; @@ -2129,10 +2129,7 @@ class CommandDeleteToLineEnd extends BaseCommand { const linesDown = (vimState.recordedState.count || 1) - 1; const start = position; - const end = position - .getDownByCount(linesDown) - .getLineEnd() - .getLeftThroughLineBreaks(); + const end = position.getDownByCount(linesDown).getLineEnd().getLeftThroughLineBreaks(); return new operator.DeleteOperator(this.multicursorIndex).run(vimState, start, end); } @@ -3188,7 +3185,7 @@ class ActionJoin extends BaseCommand { let i = 0; const cursorsToIterateOver = vimState.cursors - .map(x => new Range(x.start, x.stop)) + .map((x) => new Range(x.start, x.stop)) .sort((a, b) => a.start.line > b.start.line || (a.start.line === b.start.line && a.start.character > b.start.character) @@ -3285,10 +3282,7 @@ class ActionJoinNoWhitespace extends BaseCommand { vimState, position.getLineBegin(), lineTwo.length > 0 - ? position - .getNextLineBegin() - .getLineEnd() - .getLeft() + ? position.getNextLineBegin().getLineEnd().getLeft() : position.getLineEnd() ); @@ -4070,7 +4064,7 @@ class ActionOverrideCmdD extends BaseCommand { // If this is the first cursor, select 1 character less // so that only the word is selected, no extra character - vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop.getLeft())); + vimState.cursors = vimState.cursors.map((x) => x.withNewStop(x.stop.getLeft())); await vimState.setCurrentMode(Mode.Visual); @@ -4097,10 +4091,7 @@ class ActionOverrideCmdDInsert extends BaseCommand { if (idx === 0) { return new vscode.Selection( curPos.getWordLeft(false), - curPos - .getLeft() - .getCurrentWordEnd(true) - .getRight() + curPos.getLeft().getCurrentWordEnd(true).getRight() ); } else { // Since we're adding the selections ourselves, we need to make sure @@ -4109,10 +4100,8 @@ class ActionOverrideCmdDInsert extends BaseCommand { vscode.window.activeTextEditor!.selections[0].active ); const matchWordLength = - matchWordPos - .getLeft() - .getCurrentWordEnd(true) - .getRight().character - matchWordPos.getWordLeft(false).character; + matchWordPos.getLeft().getCurrentWordEnd(true).getRight().character - + matchWordPos.getWordLeft(false).character; const wordBegin = curPos.getLeftByCount(matchWordLength); return new vscode.Selection(wordBegin, curPos); } diff --git a/src/actions/commands/commandLine.ts b/src/actions/commands/commandLine.ts index 04a898955..3f3e6df26 100644 --- a/src/actions/commands/commandLine.ts +++ b/src/actions/commands/commandLine.ts @@ -61,7 +61,7 @@ class CommandTabInCommandline extends BaseCommand { if ( commandLine.autoCompleteItems.length !== 0 && - this.keys.some(k => commandLine.lastKeyPressed === k[0]) + this.keys.some((k) => commandLine.lastKeyPressed === k[0]) ) { this.cycleCompletion(vimState, isTabForward); commandLine.lastKeyPressed = key; @@ -82,9 +82,9 @@ class CommandTabInCommandline extends BaseCommand { if (cmdRegex.test(evalCmd)) { // Command completion newCompletionItems = Object.keys(commandParsers) - .filter(cmd => cmd.startsWith(evalCmd)) + .filter((cmd) => cmd.startsWith(evalCmd)) // Remove the already typed portion in the array - .map(cmd => cmd.slice(cmd.search(evalCmd) + evalCmd.length)) + .map((cmd) => cmd.slice(cmd.search(evalCmd) + evalCmd.length)) .sort(); } else if (fileRegex.exec(evalCmd)) { // File completion by searching if there is a space after the first word/command @@ -111,8 +111,8 @@ class CommandTabInCommandline extends BaseCommand { shouldAddDotItems ); newCompletionItems = dirItems - .filter(name => name.startsWith(baseName)) - .map(name => name.slice(name.search(baseName) + baseName.length)) + .filter((name) => name.startsWith(baseName)) + .map((name) => name.slice(name.search(baseName) + baseName.length)) .sort(); } diff --git a/src/actions/commands/insert.ts b/src/actions/commands/insert.ts index 52734af7d..6a43e88b1 100644 --- a/src/actions/commands/insert.ts +++ b/src/actions/commands/insert.ts @@ -32,9 +32,9 @@ class CommandEscInsertMode extends BaseCommand { } public async exec(position: Position, vimState: VimState): Promise { - vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop.getLeft())); + vimState.cursors = vimState.cursors.map((x) => x.withNewStop(x.stop.getLeft())); if (vimState.returnToInsertAfterCommand && position.character !== 0) { - vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop.getRight())); + vimState.cursors = vimState.cursors.map((x) => x.withNewStop(x.stop.getRight())); } // only remove leading spaces inserted by vscode. @@ -339,10 +339,7 @@ class CommandInsertDigraph extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { const digraph = this.keysPressed.slice(1, 3).join(''); - const reverseDigraph = digraph - .split('') - .reverse() - .join(''); + const reverseDigraph = digraph.split('').reverse().join(''); let charCodes = (DefaultDigraphs[digraph] || DefaultDigraphs[reverseDigraph] || configuration.digraphs[digraph] || @@ -364,10 +361,7 @@ class CommandInsertDigraph extends BaseCommand { return false; } const chars = keysPressed.slice(1, 3).join(''); - const reverseChars = chars - .split('') - .reverse() - .join(''); + const reverseChars = chars.split('').reverse().join(''); return ( chars in configuration.digraphs || reverseChars in configuration.digraphs || @@ -381,10 +375,7 @@ class CommandInsertDigraph extends BaseCommand { return false; } const chars = keysPressed.slice(1, keysPressed.length).join(''); - const reverseChars = chars - .split('') - .reverse() - .join(''); + const reverseChars = chars.split('').reverse().join(''); if (chars.length > 0) { const predicate = (digraph: string) => { const digraphChars = digraph.substring(0, chars.length); diff --git a/src/actions/operator.ts b/src/actions/operator.ts index 59838490e..43384f1a2 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -71,7 +71,7 @@ export class BaseOperator extends BaseAction { public doesRepeatedOperatorApply(vimState: VimState, keysPressed: string[]) { const nonCountActions = vimState.recordedState.actionsRun.filter( - x => !(x instanceof CommandNumber) + (x) => !(x instanceof CommandNumber) ); const prevAction = nonCountActions[nonCountActions.length - 1]; return ( diff --git a/src/actions/plugins/easymotion/easymotion.ts b/src/actions/plugins/easymotion/easymotion.ts index dccaebf28..281be21f8 100644 --- a/src/actions/plugins/easymotion/easymotion.ts +++ b/src/actions/plugins/easymotion/easymotion.ts @@ -107,7 +107,7 @@ export class EasyMotion { */ public findMarkers(nail: string, onlyVisible: boolean): EasyMotion.Marker[] { const markers = onlyVisible ? this.visibleMarkers : this._markers; - return markers.filter(marker => marker.name.startsWith(nail)); + return markers.filter((marker) => marker.name.startsWith(nail)); } /** @@ -225,7 +225,7 @@ export class EasyMotion { this.decorations = []; // Ignore markers that do not start with the accumulated depth level - for (const marker of this._markers.filter(m => m.name.startsWith(this.accumulation))) { + for (const marker of this._markers.filter((m) => m.name.startsWith(this.accumulation))) { const pos = marker.position; // Get keys after the depth we're at const keystroke = marker.name.substr(this.accumulation.length); diff --git a/src/actions/plugins/surround.ts b/src/actions/plugins/surround.ts index 565756c19..f78a1583a 100644 --- a/src/actions/plugins/surround.ts +++ b/src/actions/plugins/surround.ts @@ -136,10 +136,7 @@ class CommandSurroundModeRepeat extends BaseMovement { public async execAction(position: Position, vimState: VimState): Promise { return { start: position.getLineBeginRespectingIndent(), - stop: position - .getLineEnd() - .getLastWordEnd() - .getRight(), + stop: position.getLineEnd().getLastWordEnd().getRight(), }; } diff --git a/src/actions/textobject.ts b/src/actions/textobject.ts index 613fb2773..195405466 100644 --- a/src/actions/textobject.ts +++ b/src/actions/textobject.ts @@ -187,7 +187,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection { vimState.cursorStartPosition = cursorStartPos; } - ranges = ranges.filter(range => { + ranges = ranges.filter((range) => { return !range.failed; }); diff --git a/src/cmd_line/commandLine.ts b/src/cmd_line/commandLine.ts index 2fae79f1f..f9ce88f4b 100644 --- a/src/cmd_line/commandLine.ts +++ b/src/cmd_line/commandLine.ts @@ -128,16 +128,10 @@ class CommandLine { this._history.add(initialText); - let cmd = await vscode.window.showQuickPick( - this._history - .get() - .slice() - .reverse(), - { - placeHolder: 'Vim command history', - ignoreFocusOut: false, - } - ); + let cmd = await vscode.window.showQuickPick(this._history.get().slice().reverse(), { + placeHolder: 'Vim command history', + ignoreFocusOut: false, + }); return cmd; } diff --git a/src/cmd_line/commands/digraph.ts b/src/cmd_line/commands/digraph.ts index 24dc4a43a..8d7136264 100644 --- a/src/cmd_line/commands/digraph.ts +++ b/src/cmd_line/commands/digraph.ts @@ -47,7 +47,7 @@ export class DigraphsCommand extends node.CommandBase { this.makeQuickPicks(DefaultDigraphs) ); - vscode.window.showQuickPick(digraphKeyAndContent).then(async val => { + vscode.window.showQuickPick(digraphKeyAndContent).then(async (val) => { if (val) { const char = String.fromCharCode(...val.charCodes); await TextEditor.insert(char); diff --git a/src/cmd_line/commands/file.ts b/src/cmd_line/commands/file.ts index 62ad4ac25..767685f10 100644 --- a/src/cmd_line/commands/file.ts +++ b/src/cmd_line/commands/file.ts @@ -69,7 +69,7 @@ export class FileCommand extends node.CommandBase { split = true; } - let hidePreviousEditor = async function() { + let hidePreviousEditor = async function () { if (split === true) { await vscode.commands.executeCommand('workbench.action.previousEditor'); await vscode.commands.executeCommand('workbench.action.closeActiveEditor'); diff --git a/src/cmd_line/commands/marks.ts b/src/cmd_line/commands/marks.ts index 6ee3b37d4..0e04da6b2 100644 --- a/src/cmd_line/commands/marks.ts +++ b/src/cmd_line/commands/marks.ts @@ -34,10 +34,10 @@ export class MarksCommand extends node.CommandBase { async execute(vimState: VimState): Promise { const quickPickItems: MarkQuickPickItem[] = vimState.historyTracker .getMarks() - .filter(mark => { + .filter((mark) => { return !this.marksFilter || this.marksFilter.includes(mark.name); }) - .map(mark => new MarkQuickPickItem(mark)); + .map((mark) => new MarkQuickPickItem(mark)); if (quickPickItems.length > 0) { const item = await window.showQuickPick(quickPickItems, { diff --git a/src/cmd_line/commands/quit.ts b/src/cmd_line/commands/quit.ts index 8ba9e3ff6..e71633640 100644 --- a/src/cmd_line/commands/quit.ts +++ b/src/cmd_line/commands/quit.ts @@ -29,7 +29,7 @@ export class QuitCommand extends node.CommandBase { // NOTE: We can't currently get all open text editors, so this isn't perfect. See #3809 const duplicatedInSplit = vscode.window.visibleTextEditors.filter( - editor => editor.document === this.activeTextEditor!.document + (editor) => editor.document === this.activeTextEditor!.document ).length > 1; if ( this.activeTextEditor!.document.isDirty && diff --git a/src/cmd_line/commands/register.ts b/src/cmd_line/commands/register.ts index eec75e357..1531b1ee6 100644 --- a/src/cmd_line/commands/register.ts +++ b/src/cmd_line/commands/register.ts @@ -25,7 +25,7 @@ export class RegisterCommand extends node.CommandBase { if (result instanceof Array) { result = result.join('\n').substr(0, 100); } else if (result instanceof RecordedState) { - result = result.actionsRun.map(x => x.keysPressed.join('')).join(''); + result = result.actionsRun.map((x) => x.keysPressed.join('')).join(''); } return result; @@ -42,7 +42,7 @@ export class RegisterCommand extends node.CommandBase { await this.displayRegisterValue(this.arguments.registers[0]); } else { const currentRegisterKeys = Register.getKeys().filter( - reg => + (reg) => reg !== '_' && (this.arguments.registers.length === 0 || this.arguments.registers.includes(reg)) ); @@ -55,7 +55,7 @@ export class RegisterCommand extends node.CommandBase { }); } - vscode.window.showQuickPick(registerKeyAndContent).then(async val => { + vscode.window.showQuickPick(registerKeyAndContent).then(async (val) => { if (val) { let result = val.description; vscode.window.showInformationMessage(`${val.label} ${result}`); diff --git a/src/cmd_line/commands/write.ts b/src/cmd_line/commands/write.ts index 0daeac236..77b9ed0cb 100644 --- a/src/cmd_line/commands/write.ts +++ b/src/cmd_line/commands/write.ts @@ -87,7 +87,7 @@ export class WriteCommand extends node.CommandBase { 'C written'; StatusBar.setText(vimState, text); }, - e => StatusBar.setText(vimState, e) + (e) => StatusBar.setText(vimState, e) ) ); } diff --git a/src/cmd_line/lexer.ts b/src/cmd_line/lexer.ts index 3f2f79615..dd1c056da 100644 --- a/src/cmd_line/lexer.ts +++ b/src/cmd_line/lexer.ts @@ -128,7 +128,7 @@ namespace LexerFunctions { * so it's lexRange's job to specify which token to emit. */ function lexDigits(tokenType: TokenType) { - return function(state: Scanner, tokens: Token[]): ILexFunction | null { + return function (state: Scanner, tokens: Token[]): ILexFunction | null { // The first digit has already been lexed. while (true) { if (state.isAtEof) { diff --git a/src/cmd_line/node.ts b/src/cmd_line/node.ts index fedcef24c..39936c5bd 100644 --- a/src/cmd_line/node.ts +++ b/src/cmd_line/node.ts @@ -95,7 +95,7 @@ export class LineRange { case token.TokenType.SelectionFirstLine: currentLineNum = Math.min.apply( null, - doc.selections.map(selection => + doc.selections.map((selection) => selection.start.isBeforeOrEqual(selection.end) ? selection.start.line : selection.end.line @@ -105,7 +105,7 @@ export class LineRange { case token.TokenType.SelectionLastLine: currentLineNum = Math.max.apply( null, - doc.selections.map(selection => + doc.selections.map((selection) => selection.start.isAfter(selection.end) ? selection.start.line : selection.end.line ) ); diff --git a/src/cmd_line/scanner.ts b/src/cmd_line/scanner.ts index ca499dd8d..3836f9c4b 100644 --- a/src/cmd_line/scanner.ts +++ b/src/cmd_line/scanner.ts @@ -158,7 +158,7 @@ export class Scanner { } expectOneOf(values: string[]): void { - let match = values.filter(s => this.input.substr(this.pos).startsWith(s)); + let match = values.filter((s) => this.input.substr(this.pos).startsWith(s)); if (match.length !== 1) { if (match.length > 1) { throw new Error('Too many matches.'); diff --git a/src/common/matching/tagMatcher.ts b/src/common/matching/tagMatcher.ts index a444428f3..d4bb0748e 100644 --- a/src/common/matching/tagMatcher.ts +++ b/src/common/matching/tagMatcher.ts @@ -78,7 +78,7 @@ export class TagMatcher { const startPos = TextEditor.getOffsetAt(vimState.cursorStartPosition); const endPos = position; - const tagsSurrounding = matchedTags.filter(n => { + const tagsSurrounding = matchedTags.filter((n) => { return startPos > n.openingTagStart && endPos < n.closingTagEnd; }); diff --git a/src/common/motion/position.ts b/src/common/motion/position.ts index 99c5db491..0c63c3015 100644 --- a/src/common/motion/position.ts +++ b/src/common/motion/position.ts @@ -370,9 +370,7 @@ export class Position extends vscode.Position { if (includeEol) { return this.getUp(0).getLineEnd(); } else { - return this.getUp(0) - .getLineEnd() - .getLeft(); + return this.getUp(0).getLineEnd().getLeft(); } } @@ -997,8 +995,8 @@ export class Position extends vscode.Position { const escapedKeywordChars = _.escapeRegExp(keywordChars).replace(/-/g, '\\-'); codePointRangePatterns[Number(CharKind.Punctuation)].push(escapedKeywordChars); - const codePointRanges = codePointRangePatterns.map(patterns => patterns.join('')); - const symbolSegments = codePointRanges.map(range => `([${range}]+)`); + const codePointRanges = codePointRangePatterns.map((patterns) => patterns.join('')); + const symbolSegments = codePointRanges.map((range) => `([${range}]+)`); // wordSegment matches word characters. // A word character is a symbol which is neither @@ -1061,7 +1059,7 @@ export class Position extends vscode.Position { const positions = Position.getAllPositions(text, regex); return positions .reverse() - .find(index => (index < pos && !inclusive) || (index <= pos && inclusive) || forceFirst); + .find((index) => (index < pos && !inclusive) || (index <= pos && inclusive) || forceFirst); } /** @@ -1092,7 +1090,7 @@ export class Position extends vscode.Position { for (let currentLine = this.line; currentLine < TextEditor.getLineCount(); currentLine++) { let positions = Position.getAllPositions(TextEditor.getLine(currentLine).text, regex); let newCharacter = positions.find( - index => + (index) => (index > this.character && !inclusive) || (index >= this.character && inclusive) || currentLine !== this.line @@ -1115,7 +1113,7 @@ export class Position extends vscode.Position { } // reverse the list to find the biggest element smaller than this.character positions = positions.reverse(); - let index = positions.findIndex(i => i < this.character || currentLine !== this.line); + let index = positions.findIndex((i) => i < this.character || currentLine !== this.line); let newCharacter = 0; if (index === -1) { if (currentLine > -1) { @@ -1141,7 +1139,7 @@ export class Position extends vscode.Position { for (let currentLine = this.line; currentLine < TextEditor.getLineCount(); currentLine++) { let positions = this.getAllEndPositions(TextEditor.getLine(currentLine).text, regex); let newCharacter = positions.find( - index => + (index) => (index > this.character && !inclusive) || (index >= this.character && inclusive) || currentLine !== this.line @@ -1159,7 +1157,7 @@ export class Position extends vscode.Position { let paragraphBegin = this.getCurrentParagraphBeginning(); for (let currentLine = this.line; currentLine >= paragraphBegin.line; currentLine--) { let endPositions = this.getAllEndPositions(TextEditor.getLine(currentLine).text, regex); - let newCharacter = endPositions.reverse().find(index => { + let newCharacter = endPositions.reverse().find((index) => { const newPositionBeforeThis = new Position(currentLine, index) .getRightThroughLineBreaks() .compareTo(this); @@ -1185,7 +1183,7 @@ export class Position extends vscode.Position { for (let currentLine = this.line; currentLine <= paragraphEnd.line; currentLine++) { let endPositions = this.getAllEndPositions(TextEditor.getLine(currentLine).text, regex); let newCharacter = endPositions.find( - index => + (index) => (index > this.character && !inclusive) || (index >= this.character && inclusive) || currentLine !== this.line @@ -1204,7 +1202,7 @@ export class Position extends vscode.Position { for (let currentLine = this.line; currentLine <= paragraphEnd.line; currentLine++) { let allPositions = Position.getAllPositions(TextEditor.getLine(currentLine).text, regex); let newCharacter = allPositions.find( - index => + (index) => (index > this.character && !inclusive) || (index >= this.character && inclusive) || currentLine !== this.line @@ -1230,7 +1228,7 @@ export class Position extends vscode.Position { /\S/g ); const newCharacter = nonWhitePositions.find( - index => + (index) => (index > this.character && !inclusive) || (index >= this.character && inclusive) || currentLine !== this.line diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index 357cadddb..e914b2b1e 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -395,9 +395,9 @@ function overlapSetting(args: { defaultValue: OptionValue; map?: Map; }) { - return function(target: any, propertyKey: string) { + return function (target: any, propertyKey: string) { Object.defineProperty(target, propertyKey, { - get: function() { + get: function () { // retrieve value from vim configuration // if the value is not defined or empty // look at the equivalent `editor` setting @@ -414,7 +414,7 @@ function overlapSetting(args: { return val; }, - set: function(value) { + set: function (value) { // synchronize the vim setting with the `editor` equivalent this['_' + propertyKey] = value; diff --git a/src/configuration/iconfigurationValidator.ts b/src/configuration/iconfigurationValidator.ts index 61b56ebd3..73e9fd7b0 100644 --- a/src/configuration/iconfigurationValidator.ts +++ b/src/configuration/iconfigurationValidator.ts @@ -21,7 +21,7 @@ export class ValidatorResults { } public get numErrors(): number { - return this.errors.filter(e => e.level === 'error').length; + return this.errors.filter((e) => e.level === 'error').length; } public get hasError(): boolean { @@ -29,7 +29,7 @@ export class ValidatorResults { } public get numWarnings(): number { - return this.errors.filter(e => e.level === 'warning').length; + return this.errors.filter((e) => e.level === 'warning').length; } public get hasWarning(): boolean { diff --git a/src/configuration/remapper.ts b/src/configuration/remapper.ts index 0d4dcfe61..bf4029878 100644 --- a/src/configuration/remapper.ts +++ b/src/configuration/remapper.ts @@ -37,7 +37,7 @@ export class Remappers implements IRemapper { } get isPotentialRemap(): boolean { - return this.remappers.some(r => r.isPotentialRemap); + return this.remappers.some((r) => r.isPotentialRemap); } public async sendKey( @@ -138,7 +138,9 @@ export class Remapper implements IRemapper { await vimState.historyTracker.undoAndRemoveChanges( Math.max(0, numCharsToRemove * vimState.cursors.length) ); - vimState.cursors = vimState.cursors.map(c => c.withNewStop(c.stop.getLeft(numCharsToRemove))); + vimState.cursors = vimState.cursors.map((c) => + c.withNewStop(c.stop.getLeft(numCharsToRemove)) + ); } // We need to remove the keys that were remapped into different keys from the state. vimState.recordedState.actionKeys = vimState.recordedState.actionKeys.slice( @@ -231,7 +233,7 @@ export class Remapper implements IRemapper { if (remappings.size === 0) { return [0, 0]; } - const keyLengths = Array.from(remappings.keys()).map(k => k.length); + const keyLengths = Array.from(remappings.keys()).map((k) => k.length); return [Math.min(...keyLengths), Math.max(...keyLengths)]; } } diff --git a/src/configuration/validators/neovimValidator.ts b/src/configuration/validators/neovimValidator.ts index e837a6408..9327eace9 100644 --- a/src/configuration/validators/neovimValidator.ts +++ b/src/configuration/validators/neovimValidator.ts @@ -16,7 +16,7 @@ export class NeovimValidator implements IConfigurationValidator { if (config.neovimPath === '') { const pathVar = process.env.PATH; if (pathVar) { - pathVar.split(';').forEach(element => { + pathVar.split(';').forEach((element) => { let neovimExecutable = 'nvim'; if (process.platform === 'win32') { neovimExecutable += '.exe'; diff --git a/src/configuration/validators/remappingValidator.ts b/src/configuration/validators/remappingValidator.ts index 8c054c162..8a04b6e9f 100644 --- a/src/configuration/validators/remappingValidator.ts +++ b/src/configuration/validators/remappingValidator.ts @@ -125,7 +125,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 30211d817..d5d09b245 100644 --- a/src/configuration/vimrc.ts +++ b/src/configuration/vimrc.ts @@ -95,9 +95,9 @@ class VimrcImpl { } })(); - mappings?.forEach(remaps => { + mappings?.forEach((remaps) => { // Don't override a mapping present in settings.json; those are more specific to VSCodeVim. - if (!remaps.some(r => _.isEqual(r.before, remap!.keyRemapping.before))) { + if (!remaps.some((r) => _.isEqual(r.before, remap!.keyRemapping.before))) { remaps.push(remap.keyRemapping); } }); @@ -115,7 +115,7 @@ class VimrcImpl { config.commandLineModeKeyBindingsNonRecursive, ]; for (const remaps of remapCollections) { - _.remove(remaps, remap => remap.source === 'vimrc'); + _.remove(remaps, (remap) => remap.source === 'vimrc'); } } diff --git a/src/history/historyTracker.ts b/src/history/historyTracker.ts index 5f777e74e..9db602e1e 100644 --- a/src/history/historyTracker.ts +++ b/src/history/historyTracker.ts @@ -196,14 +196,8 @@ class HistoryStep { return `1 second ago`; } else if (timeDiffSeconds >= 100) { const hours = this.timestamp.getHours(); - const minutes = this.timestamp - .getMinutes() - .toString() - .padStart(2, '0'); - const seconds = this.timestamp - .getSeconds() - .toString() - .padStart(2, '0'); + const minutes = this.timestamp.getMinutes().toString().padStart(2, '0'); + const seconds = this.timestamp.getSeconds().toString().padStart(2, '0'); return `${hours}:${minutes}:${seconds}`; } else { return `${timeDiffSeconds} seconds ago`; @@ -412,9 +406,9 @@ export class HistoryTracker { */ private updateMarks(): void { const newMarks = this.updateAndReturnMarks(); - this.currentHistoryStep.marks = newMarks.filter(mark => !mark.isUppercaseMark); + this.currentHistoryStep.marks = newMarks.filter((mark) => !mark.isUppercaseMark); - newMarks.filter(mark => mark.isUppercaseMark).forEach(this.putMarkInList.bind); + newMarks.filter((mark) => mark.isUppercaseMark).forEach(this.putMarkInList.bind); } /** @@ -430,7 +424,7 @@ export class HistoryTracker { */ private getAllCurrentDocumentMarks(): IMark[] { const globalMarks = HistoryStep.globalMarks.filter( - mark => mark.editor === vscode.window.activeTextEditor + (mark) => mark.editor === vscode.window.activeTextEditor ); return [...this.currentHistoryStep.marks, ...globalMarks]; } @@ -455,7 +449,7 @@ export class HistoryTracker { */ private putMarkInList(mark: IMark): void { const marks = this.getMarkList(mark.isUppercaseMark); - const previousIndex = marks.findIndex(existingMark => existingMark.name === mark.name); + const previousIndex = marks.findIndex((existingMark) => existingMark.name === mark.name); if (previousIndex !== -1) { marks[previousIndex] = mark; } else { @@ -469,7 +463,7 @@ export class HistoryTracker { */ public getMark(markName: string): IMark { const marks = this.getMarkList(markName.toUpperCase() === markName); - return marks.find(mark => mark.name === markName); + return marks.find((mark) => mark.name === markName); } /** @@ -892,7 +886,7 @@ export class HistoryTracker { for (let i = 0; i < this.historySteps.length; i++) { const step = this.historySteps[i]; - result += step.changes.map(x => x.text.replace(/\n/g, '\\n')).join(''); + result += step.changes.map((x) => x.text.replace(/\n/g, '\\n')).join(''); if (this.currentHistoryStepIndex === i) { result += '+'; } diff --git a/src/jumps/jumpTracker.ts b/src/jumps/jumpTracker.ts index 99ae43f9b..8e2ef8de0 100644 --- a/src/jumps/jumpTracker.ts +++ b/src/jumps/jumpTracker.ts @@ -130,7 +130,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) { @@ -250,7 +250,7 @@ export class JumpTracker { // Get distance from newlines in the text added. // Unlike handleTextDeleted, the range parameter distance between start/end is generally zero, // just showing where the text was added. - const distance = text.split('').filter(c => c === '\n').length; + const distance = text.split('').filter((c) => c === '\n').length; this._jumps.forEach((jump, i) => { const jumpIsAfterAddedText = @@ -346,7 +346,7 @@ export class JumpTracker { } private clearJumpsOnSamePosition(jump: Jump): void { - this._jumps = this._jumps.filter(j => j === jump || !j.isSamePosition(jump)); + this._jumps = this._jumps.filter((j) => j === jump || !j.isSamePosition(jump)); } private removeDuplicateJumps() { diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 461676ae7..6e60eda2f 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -127,7 +127,7 @@ export class ModeHandler implements vscode.Disposable { ) { // Number of selections changed, make sure we know about all of them still this.vimState.cursors = e.textEditor.selections.map( - sel => + (sel) => new Range( // Adjust the cursor positions because cursors & selections don't match exactly sel.anchor.isAfter(sel.active) @@ -349,7 +349,7 @@ export class ModeHandler implements vscode.Disposable { } // Catch any text change not triggered by us (example: tab completion). - vimState.historyTracker.addChange(this.vimState.cursorsInitialState.map(c => c.stop)); + vimState.historyTracker.addChange(this.vimState.cursorsInitialState.map((c) => c.stop)); vimState.keyHistory.push(key); @@ -388,7 +388,7 @@ export class ModeHandler implements vscode.Disposable { } else { // Push document content change to the stack lastAction.contentChanges = lastAction.contentChanges.concat( - vimState.historyTracker.currentContentChanges.map(diff => ({ + vimState.historyTracker.currentContentChanges.map((diff) => ({ textDiff: diff, positionDiff: new PositionDiff(), })) @@ -472,7 +472,7 @@ export class ModeHandler implements vscode.Disposable { */ if (vimState.currentMode === Mode.Visual) { - vimState.cursors = vimState.cursors.map(c => + vimState.cursors = vimState.cursors.map((c) => c.start.isBefore(c.stop) ? c.withNewStop(c.stop.getLeftThroughLineBreaks(true)) : c ); } @@ -534,7 +534,7 @@ export class ModeHandler implements vscode.Disposable { } if (vimState.currentMode === Mode.Visual) { - vimState.cursors = vimState.cursors.map(c => + vimState.cursors = vimState.cursors.map((c) => c.start.isBefore(c.stop) ? c.withNewStop( c.stop.isLineEnd() ? c.stop.getRightThroughLineBreaks() : c.stop.getRight() @@ -610,7 +610,7 @@ export class ModeHandler implements vscode.Disposable { this.vimState.alteredHistory = false; vimState.historyTracker.ignoreChange(); } else { - vimState.historyTracker.addChange(this.vimState.cursorsInitialState.map(c => c.stop)); + vimState.historyTracker.addChange(this.vimState.cursorsInitialState.map((c) => c.stop)); } } @@ -660,7 +660,7 @@ export class ModeHandler implements vscode.Disposable { } // Update the current history step to have the latest cursor position - vimState.historyTracker.setLastHistoryEndPosition(vimState.cursors.map(c => c.stop)); + vimState.historyTracker.setLastHistoryEndPosition(vimState.cursors.map((c) => c.stop)); if (isVisualMode(this.vimState.currentMode) && !this.vimState.isRunningDotCommand) { // Store selection for commands like gv @@ -800,7 +800,7 @@ export class ModeHandler implements vscode.Disposable { // Keep track of all cursors (in the case of multi-cursor). vimState.cursors = resultingCursors; vimState.editor.selections = vimState.cursors.map( - cursor => new vscode.Selection(cursor.start, cursor.stop) + (cursor) => new vscode.Selection(cursor.start, cursor.stop) ); } @@ -872,7 +872,7 @@ export class ModeHandler implements vscode.Disposable { // TODO: Select one transformation for every cursor and run them all // in parallel. Repeat till there are no more transformations. for (const transformation of textTransformations) { - await this.vimState.editor.edit(edit => doTextEditorEdit(transformation, edit)); + await this.vimState.editor.edit((edit) => doTextEditorEdit(transformation, edit)); } } else { // This is the common case! @@ -882,7 +882,7 @@ export class ModeHandler implements vscode.Disposable { * (this is primarily necessary for multi-cursor mode, since most * actions will trigger at most one text operation). */ - await this.vimState.editor.edit(edit => { + await this.vimState.editor.edit((edit) => { for (const command of textTransformations) { doTextEditorEdit(command, edit); } @@ -1011,7 +1011,7 @@ export class ModeHandler implements vscode.Disposable { } } - const selections = this.vimState.editor.selections.map(sel => { + const selections = this.vimState.editor.selections.map((sel) => { let range = Range.FromVSCodeSelection(sel); if (range.start.isBefore(range.stop)) { range = range.withNewStop(range.stop.getLeftThroughLineBreaks(true)); @@ -1151,7 +1151,7 @@ export class ModeHandler implements vscode.Disposable { if ( args.drawSelection && !vimState.recordedState.actionsRun.some( - action => action instanceof DocumentContentChangeAction + (action) => action instanceof DocumentContentChangeAction ) ) { let selectionMode: Mode = vimState.currentMode; @@ -1232,7 +1232,7 @@ export class ModeHandler implements vscode.Disposable { // Scroll to position of cursor if ( vimState.editor.visibleRanges.length > 0 && - !vimState.postponedCodeViewChanges.some(change => change.command === 'editorScroll') + !vimState.postponedCodeViewChanges.some((change) => change.command === 'editorScroll') ) { const isCursorAboveRange = (visibleRange: vscode.Range): boolean => visibleRange.start.line - vimState.cursorStopPosition.line >= 15; @@ -1338,7 +1338,7 @@ export class ModeHandler implements vscode.Disposable { this.currentMode === Mode.EasyMotionInputMode ? vimState.easyMotion.searchAction .getMatches(vimState.cursorStopPosition, vimState) - .map(match => match.toRange()) + .map((match) => match.toRange()) : []; this.vimState.editor.setDecorations(decoration.EasyMotion, easyMotionHighlightRanges); @@ -1395,6 +1395,6 @@ export class ModeHandler implements vscode.Disposable { } dispose() { - this._disposables.map(d => d.dispose()); + this._disposables.map((d) => d.dispose()); } } diff --git a/src/neovim/neovim.ts b/src/neovim/neovim.ts index 3259b9024..b365ace6c 100644 --- a/src/neovim/neovim.ts +++ b/src/neovim/neovim.ts @@ -89,7 +89,7 @@ export class NeovimWrapper implements vscode.Disposable { cwd: dir, }); - this.process.on('error', err => { + this.process.on('error', (err) => { this.logger.error(`Error spawning neovim. ${err.message}.`); configuration.enableNeovim = false; }); diff --git a/src/register/register.ts b/src/register/register.ts index 2a5dab6bd..709dbfcc7 100644 --- a/src/register/register.ts +++ b/src/register/register.ts @@ -324,7 +324,7 @@ export class Register { if (baseOperator instanceof YankOperator || baseOperator instanceof CommandYankFullLine) { // 'yank' to 0 only if no register was specified - const registerCommand = vimState.recordedState.actionsRun.find(value => { + const registerCommand = vimState.recordedState.actionsRun.find((value) => { return value instanceof CommandRegister; }); diff --git a/src/state/globalState.ts b/src/state/globalState.ts index 81d9eccbc..ebd81c1bf 100644 --- a/src/state/globalState.ts +++ b/src/state/globalState.ts @@ -57,7 +57,7 @@ class GlobalState { await this._searchHistory.load(); this._searchHistory .get() - .forEach(val => + .forEach((val) => this.searchStatePrevious.push( new SearchState(SearchDirection.Forward, new Position(0, 0), val, undefined, Mode.Normal) ) @@ -110,7 +110,7 @@ class GlobalState { const items = this._searchStatePrevious .slice() .reverse() - .map(searchState => { + .map((searchState) => { return { label: searchState.searchString, searchState: searchState, diff --git a/src/state/recordedState.ts b/src/state/recordedState.ts index 2bc1a09d9..cb25a6e4a 100644 --- a/src/state/recordedState.ts +++ b/src/state/recordedState.ts @@ -117,14 +117,14 @@ export class RecordedState { } public get operators(): BaseOperator[] { - return this.actionsRun.filter(a => a instanceof BaseOperator).reverse() as BaseOperator[]; + return this.actionsRun.filter((a) => a instanceof BaseOperator).reverse() as BaseOperator[]; } /** * The command (e.g. i, ., R, /) the user wants to run, if there is one. */ public get command(): BaseCommand { - const list = this.actionsRun.filter(a => a instanceof BaseCommand).reverse(); + const list = this.actionsRun.filter((a) => a instanceof BaseCommand).reverse(); // TODO - disregard , then assert this is of length 1. @@ -132,7 +132,7 @@ export class RecordedState { } public get hasRunAMovement(): boolean { - return this.actionsRun.some(a => a.isMotion); + return this.actionsRun.some((a) => a.isMotion); } /** diff --git a/src/state/searchState.ts b/src/state/searchState.ts index 6b291942c..df35f8676 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -164,7 +164,7 @@ export class SearchState { // through it in order to find the current line and character. const finalPos = new Position(TextEditor.getLineCount() - 1, 0).getLineEndIncludingEOL(); const text = TextEditor.getText(new vscode.Range(new Position(0, 0), finalPos)); - const lineLengths = text.split('\n').map(x => x.length + 1); + const lineLengths = text.split('\n').map((x) => x.length + 1); let sumLineLengths: number[] = []; let curLength = 0; for (const length of lineLengths) { @@ -318,10 +318,7 @@ export class SearchState { return undefined; } } else { - for (let [index, matchRange] of this._matchRanges - .slice(0) - .reverse() - .entries()) { + for (let [index, matchRange] of this._matchRanges.slice(0).reverse().entries()) { if (matchRange.end.isBeforeOrEqual(startPosition)) { return { start: Position.FromVSCodePosition(matchRange.start), diff --git a/src/taskQueue.ts b/src/taskQueue.ts index c5d4405e8..8b45812f6 100644 --- a/src/taskQueue.ts +++ b/src/taskQueue.ts @@ -16,17 +16,14 @@ class TaskQueue { } = {}; private isRunning(queueName: string): boolean { - return ( - this._taskQueue[queueName] && - this._taskQueue[queueName].tasks.some(x => x.isRunning) - ); + return this._taskQueue[queueName] && this._taskQueue[queueName].tasks.some((x) => x.isRunning); } private numHighPriority(queueName: string): number { if (!this._taskQueue[queueName]) { return 0; } - return this._taskQueue[queueName].tasks.filter(x => x.isHighPriority).length; + return this._taskQueue[queueName].tasks.filter((x) => x.isHighPriority).length; } private async runTasks(queueName: string): Promise { @@ -52,7 +49,7 @@ class TaskQueue { * promises don't allow you to stop it. */ private dequeueTask(task: IEnqueuedTask): void { - this._taskQueue[task.queue].tasks = this._taskQueue[task.queue].tasks.filter(t => t !== task); + this._taskQueue[task.queue].tasks = this._taskQueue[task.queue].tasks.filter((t) => t !== task); } /** diff --git a/src/textEditor.ts b/src/textEditor.ts index e125bcf53..130927911 100644 --- a/src/textEditor.ts +++ b/src/textEditor.ts @@ -43,7 +43,7 @@ export class TextEditor { if (!letVSCodeHandleKeystrokes) { // const selections = vscode.window.activeTextEditor!.selections.slice(0); - await vscode.window.activeTextEditor!.edit(editBuilder => { + await vscode.window.activeTextEditor!.edit((editBuilder) => { if (!at) { at = Position.FromVSCodePosition(vscode.window.activeTextEditor!.selection.active); } @@ -62,7 +62,7 @@ export class TextEditor { * @deprecated Use InsertTextTransformation (or InsertTextVSCodeTransformation) instead. */ static async insertAt(text: string, position: vscode.Position): Promise { - return vscode.window.activeTextEditor!.edit(editBuilder => { + return vscode.window.activeTextEditor!.edit((editBuilder) => { editBuilder.insert(position, text); }); } @@ -71,7 +71,7 @@ export class TextEditor { * @deprecated Use DeleteTextTransformation or DeleteTextRangeTransformation instead. */ static async delete(range: vscode.Range): Promise { - return vscode.window.activeTextEditor!.edit(editBuilder => { + return vscode.window.activeTextEditor!.edit((editBuilder) => { editBuilder.delete(range); }); } @@ -88,7 +88,7 @@ export class TextEditor { * @deprecated. Use ReplaceTextTransformation instead. */ static async replace(range: vscode.Range, text: string): Promise { - return vscode.window.activeTextEditor!.edit(editBuilder => { + return vscode.window.activeTextEditor!.edit((editBuilder) => { editBuilder.replace(range, text); }); } diff --git a/src/util/path.ts b/src/util/path.ts index 710992d9b..aaa7107fe 100644 --- a/src/util/path.ts +++ b/src/util/path.ts @@ -232,7 +232,7 @@ export async function readDirectory( return ( directoryResult // Add the separator at the end to the path if it is a directory - .map(d => d[0] + (d[1] === vscode.FileType.Directory ? sep : '')) + .map((d) => d[0] + (d[1] === vscode.FileType.Directory ? sep : '')) // Add ./ and ../ to the result if specified .concat(addCurrentAndUp ? [`.${sep}`, `..${sep}`] : []) ); diff --git a/src/util/util.ts b/src/util/util.ts index 2a176f6bf..08efead0d 100644 --- a/src/util/util.ts +++ b/src/util/util.ts @@ -12,7 +12,7 @@ import { VimState } from '../state/vimState'; */ export function getCursorsAfterSync(): Range[] { return vscode.window.activeTextEditor!.selections.map( - x => new Range(Position.FromVSCodePosition(x.start), Position.FromVSCodePosition(x.end)) + (x) => new Range(Position.FromVSCodePosition(x.start), Position.FromVSCodePosition(x.end)) ); } diff --git a/test/cmd_line/command.test.ts b/test/cmd_line/command.test.ts index 6a8edf962..b16d22ad4 100644 --- a/test/cmd_line/command.test.ts +++ b/test/cmd_line/command.test.ts @@ -1,153 +1,153 @@ -import { getAndUpdateModeHandler } from '../../extension'; -import { ModeHandler } from '../../src/mode/modeHandler'; -import { cleanUpWorkspace, setupWorkspace, assertStatusBarEqual } from '../testUtils'; - -suite('cmd_line/search command', () => { - let modeHandler: ModeHandler; - - setup(async () => { - await setupWorkspace(); - modeHandler = await getAndUpdateModeHandler(); - }); - - teardown(cleanUpWorkspace); - - test('command can remove word in cmd line', async () => { - await modeHandler.handleMultipleKeyEvents([':', 'a', 'b', 'c', '-', '1', '2', '3', '']); - assertStatusBarEqual(':abc-|', 'Failed to remove "123"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':abc|', 'Failed to remove "-"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':|', 'Failed to remove "abc"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':|', 'Failed to remove nothing'); - }); - - test('command can remove word in search mode', async () => { - await modeHandler.handleMultipleKeyEvents(['/', 'a', 'b', 'c', '-', '1', '2', '3', '']); - assertStatusBarEqual('/abc-|', 'Failed to remove "123"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual('/abc|', 'Failed to remove "-"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual('/|', 'Failed to remove "abc"'); - - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual('/|', 'Failed to remove nothing'); - }); - - test('command can remove word in cmd line while retrain cmd on the right of the cursor', async () => { - await modeHandler.handleMultipleKeyEvents([ - ':', - 'a', - 'b', - 'c', - ' ', - '1', - '2', - '3', - '', - '', - '', - '', - ]); - assertStatusBarEqual(':|123', 'Failed to retain the text on the right of the cursor'); - }); - - test('command can remove word in search mode while retrain cmd on the right of the cursor', async () => { - await modeHandler.handleMultipleKeyEvents([ - '/', - 'a', - 'b', - 'c', - ' ', - '1', - '2', - '3', - '', - '', - '', - '', - ]); - assertStatusBarEqual('/|123', 'Failed to retain the text on the right of the cursor'); - }); - - test(' deletes from cursor to first character', async () => { - await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); - await modeHandler.handleMultipleKeyEvents(['', '', '']); - assertStatusBarEqual(':|yz'); - }); - - test(' puts cursor at start of command line', async () => { - await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':|s/abc/xyz'); - }); - - test(' puts cursor at start of command line', async () => { - await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':|s/abc/xyz'); - }); - - test(' puts cursor at end of command line', async () => { - await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); - await modeHandler.handleMultipleKeyEvents(['', '']); - assertStatusBarEqual(':s/abc/xyz|'); - }); - - test(' puts cursor at end of command line', async () => { - await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); - await modeHandler.handleMultipleKeyEvents(['', '']); - assertStatusBarEqual(':s/abc/xyz|'); - }); - - test('/ go to the previous/next command', async () => { - // Establish a history - :s/a/b, then :s/x/y. - // :w is the current one, not yet confirmed - await modeHandler.handleMultipleKeyEvents(':s/a/b\n'.split('')); - await modeHandler.handleMultipleKeyEvents(':s/x/y\n'.split('')); - await modeHandler.handleMultipleKeyEvents([':', 'w', '']); - - // Going backward - :s/x/y, then :s/a/b - assertStatusBarEqual(':s/x/y|'); - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':s/a/b|'); - - // Going forward again - :s/x/y, then :w (the one we started typing) - await modeHandler.handleKeyEvent(''); - assertStatusBarEqual(':s/x/y|'); - await modeHandler.handleKeyEvent(''); - - // TODO: Really, this should be `:w|`. See #4093. - assertStatusBarEqual(':|'); - }); - - test(' insert word under cursor on command line', async () => { - await modeHandler.handleMultipleKeyEvents('iabc'.split('')); - await modeHandler.handleMultipleKeyEvents(['', ':', '', '']); - assertStatusBarEqual(':abc|', 'Failed to insert word under cursor'); - }); - - test(' insert word right of cursor on command line', async () => { - await modeHandler.handleMultipleKeyEvents('i::abc'.split('')); - await modeHandler.handleMultipleKeyEvents(['', '0', ':', '', '']); - assertStatusBarEqual(':abc|', 'Failed to insert word to right of cursor'); - }); - - test(' insert word under cursor in search mode', async () => { - await modeHandler.handleMultipleKeyEvents('iabc'.split('')); - await modeHandler.handleMultipleKeyEvents(['', '/', '', '']); - assertStatusBarEqual('/abc|', 'Failed to insert word under cursor'); - }); - - test(' go to previous search string', async () => { - await modeHandler.handleMultipleKeyEvents('/abc'.split('').concat('')); - await modeHandler.handleMultipleKeyEvents(['/', '']); - assertStatusBarEqual('/abc|', 'Failed to go to previous search string'); - }); -}); +import { getAndUpdateModeHandler } from '../../extension'; +import { ModeHandler } from '../../src/mode/modeHandler'; +import { cleanUpWorkspace, setupWorkspace, assertStatusBarEqual } from '../testUtils'; + +suite('cmd_line/search command', () => { + let modeHandler: ModeHandler; + + setup(async () => { + await setupWorkspace(); + modeHandler = await getAndUpdateModeHandler(); + }); + + teardown(cleanUpWorkspace); + + test('command can remove word in cmd line', async () => { + await modeHandler.handleMultipleKeyEvents([':', 'a', 'b', 'c', '-', '1', '2', '3', '']); + assertStatusBarEqual(':abc-|', 'Failed to remove "123"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':abc|', 'Failed to remove "-"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':|', 'Failed to remove "abc"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':|', 'Failed to remove nothing'); + }); + + test('command can remove word in search mode', async () => { + await modeHandler.handleMultipleKeyEvents(['/', 'a', 'b', 'c', '-', '1', '2', '3', '']); + assertStatusBarEqual('/abc-|', 'Failed to remove "123"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual('/abc|', 'Failed to remove "-"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual('/|', 'Failed to remove "abc"'); + + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual('/|', 'Failed to remove nothing'); + }); + + test('command can remove word in cmd line while retrain cmd on the right of the cursor', async () => { + await modeHandler.handleMultipleKeyEvents([ + ':', + 'a', + 'b', + 'c', + ' ', + '1', + '2', + '3', + '', + '', + '', + '', + ]); + assertStatusBarEqual(':|123', 'Failed to retain the text on the right of the cursor'); + }); + + test('command can remove word in search mode while retrain cmd on the right of the cursor', async () => { + await modeHandler.handleMultipleKeyEvents([ + '/', + 'a', + 'b', + 'c', + ' ', + '1', + '2', + '3', + '', + '', + '', + '', + ]); + assertStatusBarEqual('/|123', 'Failed to retain the text on the right of the cursor'); + }); + + test(' deletes from cursor to first character', async () => { + await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); + await modeHandler.handleMultipleKeyEvents(['', '', '']); + assertStatusBarEqual(':|yz'); + }); + + test(' puts cursor at start of command line', async () => { + await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':|s/abc/xyz'); + }); + + test(' puts cursor at start of command line', async () => { + await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':|s/abc/xyz'); + }); + + test(' puts cursor at end of command line', async () => { + await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); + await modeHandler.handleMultipleKeyEvents(['', '']); + assertStatusBarEqual(':s/abc/xyz|'); + }); + + test(' puts cursor at end of command line', async () => { + await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split('')); + await modeHandler.handleMultipleKeyEvents(['', '']); + assertStatusBarEqual(':s/abc/xyz|'); + }); + + test('/ go to the previous/next command', async () => { + // Establish a history - :s/a/b, then :s/x/y. + // :w is the current one, not yet confirmed + await modeHandler.handleMultipleKeyEvents(':s/a/b\n'.split('')); + await modeHandler.handleMultipleKeyEvents(':s/x/y\n'.split('')); + await modeHandler.handleMultipleKeyEvents([':', 'w', '']); + + // Going backward - :s/x/y, then :s/a/b + assertStatusBarEqual(':s/x/y|'); + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':s/a/b|'); + + // Going forward again - :s/x/y, then :w (the one we started typing) + await modeHandler.handleKeyEvent(''); + assertStatusBarEqual(':s/x/y|'); + await modeHandler.handleKeyEvent(''); + + // TODO: Really, this should be `:w|`. See #4093. + assertStatusBarEqual(':|'); + }); + + test(' insert word under cursor on command line', async () => { + await modeHandler.handleMultipleKeyEvents('iabc'.split('')); + await modeHandler.handleMultipleKeyEvents(['', ':', '', '']); + assertStatusBarEqual(':abc|', 'Failed to insert word under cursor'); + }); + + test(' insert word right of cursor on command line', async () => { + await modeHandler.handleMultipleKeyEvents('i::abc'.split('')); + await modeHandler.handleMultipleKeyEvents(['', '0', ':', '', '']); + assertStatusBarEqual(':abc|', 'Failed to insert word to right of cursor'); + }); + + test(' insert word under cursor in search mode', async () => { + await modeHandler.handleMultipleKeyEvents('iabc'.split('')); + await modeHandler.handleMultipleKeyEvents(['', '/', '', '']); + assertStatusBarEqual('/abc|', 'Failed to insert word under cursor'); + }); + + test(' go to previous search string', async () => { + await modeHandler.handleMultipleKeyEvents('/abc'.split('').concat('')); + await modeHandler.handleMultipleKeyEvents(['/', '']); + assertStatusBarEqual('/abc|', 'Failed to go to previous search string'); + }); +}); diff --git a/test/cmd_line/only.test.ts b/test/cmd_line/only.test.ts index 55f6046a1..11a6fc991 100644 --- a/test/cmd_line/only.test.ts +++ b/test/cmd_line/only.test.ts @@ -9,7 +9,7 @@ import { cleanUpWorkspace, setupWorkspace, assertEqualLines } from '../testUtils const isPanelVisible = async () => withinIsolatedEditor(async () => { // Insert 1000 lines (ie. beyond veritical viewport) - await vscode.window.activeTextEditor!.edit(async editBuilder => { + await vscode.window.activeTextEditor!.edit(async (editBuilder) => { editBuilder.insert(new vscode.Position(0, 0), 'Line\n'.repeat(1000)); }); diff --git a/test/completion/lineCompletion.test.ts b/test/completion/lineCompletion.test.ts index f83776cee..9ad14d749 100644 --- a/test/completion/lineCompletion.test.ts +++ b/test/completion/lineCompletion.test.ts @@ -19,11 +19,11 @@ suite('Provide line completions', () => { teardown(cleanUpWorkspace); - const setupTestWithLines = async lines => { + const setupTestWithLines = async (lines) => { vimState.cursorStopPosition = new Position(0, 0); await modeHandler.handleKeyEvent(''); - await vimState.editor.edit(builder => { + await vimState.editor.edit((builder) => { builder.insert(new Position(0, 0), lines.join('\n')); }); await modeHandler.handleMultipleKeyEvents(['', 'g', 'g', 'j', 'j', 'A']); diff --git a/test/extension.test.ts b/test/extension.test.ts index e5aa776d0..8fbe72092 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -35,12 +35,12 @@ suite('package.json', () => { // configuration let handlers = Object.keys(srcConfiguration.configuration); - let unhandled = keys.filter(k => handlers.includes(k)); + let unhandled = keys.filter((k) => handlers.includes(k)); assert.strictEqual(unhandled.length, 0, 'Missing src handlers for ' + unhandled.join(',')); // test configuration handlers = Object.keys(new testConfiguration.Configuration()); - unhandled = keys.filter(k => handlers.includes(k)); + unhandled = keys.filter((k) => handlers.includes(k)); assert.strictEqual(unhandled.length, 0, 'Missing test handlers for ' + unhandled.join(',')); }); }); diff --git a/test/historyTracker.test.ts b/test/historyTracker.test.ts index 48ba3f1e3..95dad4757 100644 --- a/test/historyTracker.test.ts +++ b/test/historyTracker.test.ts @@ -12,10 +12,10 @@ suite('historyTracker unit tests', () => { let activeTextEditor: vscode.TextEditor; const retrieveLocalMark = (markName: string): IMark | undefined => - historyTracker.getLocalMarks().find(mark => mark.name === markName); + historyTracker.getLocalMarks().find((mark) => mark.name === markName); const retrieveFileMark = (markName: string): IMark | undefined => - historyTracker.getGlobalMarks().find(mark => mark.name === markName); + historyTracker.getGlobalMarks().find((mark) => mark.name === markName); const setupVimState = () => (sandbox.createStubInstance(VimState)); diff --git a/test/jumpTracker.test.ts b/test/jumpTracker.test.ts index 2e89e5a29..ade81ae5d 100644 --- a/test/jumpTracker.test.ts +++ b/test/jumpTracker.test.ts @@ -16,7 +16,7 @@ suite('Record and navigate jumps', () => { teardown(cleanUpWorkspace); - const newJumpTest = options => { + const newJumpTest = (options) => { return newTest({ title: `Can track jumps for keys: ${options.keysPressed.replace(/\n/g, '')}`, ...options, @@ -46,7 +46,7 @@ suite('Record and navigate jumps', () => { jumpTracker.recordJumpBack(file2); assert.deepEqual( - jumpTracker.jumps.map(j => j.fileName), + jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3'], 'Unexpected jumps found' ); @@ -75,7 +75,7 @@ suite('Record and navigate jumps', () => { jumpTracker.handleFileJump(file3, file2); assert.deepEqual( - jumpTracker.jumps.map(j => j.fileName), + jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3', 'file4'], 'Unexpected jumps found' ); @@ -97,7 +97,7 @@ suite('Record and navigate jumps', () => { jumpTracker.handleFileJump(file2, file4); assert.deepEqual( - jumpTracker.jumps.map(j => j.fileName), + jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3', 'file2'], 'Unexpected jumps found' ); @@ -113,7 +113,7 @@ suite('Record and navigate jumps', () => { jumpTracker.handleFileJump(file3, file2); assert.deepEqual( - jumpTracker.jumps.map(j => j.fileName), + jumpTracker.jumps.map((j) => j.fileName), ['file1', 'file2', 'file3'], 'Unexpected jumps found' ); @@ -129,7 +129,7 @@ suite('Record and navigate jumps', () => { assert.strictEqual(jumpTracker.jumps.length, 100, 'Jump tracker should cut off jumps at 100'); assert.deepEqual( - jumpTracker.jumps.map(j => j.position.line), + jumpTracker.jumps.map((j) => j.position.line), range(102).slice(2, 102), "Jump tracker doesn't contain the expected jumps after removing old jumps" ); @@ -146,7 +146,7 @@ suite('Record and navigate jumps', () => { jumpTracker.recordJump(jump(6, 0, 'file1'), jump(2, 0, 'file1')); assert.deepEqual( - jumpTracker.jumps.map(j => [j.position.line, j.position.character, j.fileName]), + jumpTracker.jumps.map((j) => [j.position.line, j.position.character, j.fileName]), [ [0, 0, 'file2'], [5, 0, 'file2'], @@ -169,7 +169,7 @@ suite('Record and navigate jumps', () => { // Vim doesn't delete jumps at the deleted line, it just shifts other lines down // Note the column number was preserved for newer jump when it found duplicates on a line. assert.deepEqual( - jumpTracker.jumps.map(j => [j.position.line, j.position.character, j.fileName]), + jumpTracker.jumps.map((j) => [j.position.line, j.position.character, j.fileName]), [ [0, 0, 'file2'], [5, 0, 'file2'], @@ -188,7 +188,7 @@ suite('Record and navigate jumps', () => { // If that results in multiple jumps on a line, though the duplicate is deleted // Preserve the newest jump in that case assert.deepEqual( - jumpTracker.jumps.map(j => [j.position.line, j.position.character, j.fileName]), + jumpTracker.jumps.map((j) => [j.position.line, j.position.character, j.fileName]), [ [0, 0, 'file2'], [5, 0, 'file2'], @@ -205,7 +205,7 @@ suite('Record and navigate jumps', () => { // If you delete lines such that jumps are past EOF, delete the jumps assert.deepEqual( - jumpTracker.jumps.map(j => [j.position.line, j.position.character, j.fileName]), + jumpTracker.jumps.map((j) => [j.position.line, j.position.character, j.fileName]), [ [0, 0, 'file2'], [5, 0, 'file2'], diff --git a/test/mode/modeHandlerMap.test.ts b/test/mode/modeHandlerMap.test.ts index b943996a5..fccbf137d 100644 --- a/test/mode/modeHandlerMap.test.ts +++ b/test/mode/modeHandlerMap.test.ts @@ -6,11 +6,7 @@ import { testIt } from '../testSimplifier'; import { KeypressState } from '../../src/actions/base'; function createRandomEditorIdentity(): EditorIdentity { - return new EditorIdentity( - Math.random() - .toString(36) - .substring(7) - ); + return new EditorIdentity(Math.random().toString(36).substring(7)); } suite('Mode Handler Map', () => { diff --git a/test/testSimplifier.ts b/test/testSimplifier.ts index c0098fd15..548aa3a43 100644 --- a/test/testSimplifier.ts +++ b/test/testSimplifier.ts @@ -12,12 +12,7 @@ import { globalState } from '../src/state/globalState'; export function getTestingFunctions() { const getNiceStack = (stack: string | undefined): string => { - return stack - ? stack - .split('\n') - .splice(2, 1) - .join('\n') - : 'no stack available :('; + return stack ? stack.split('\n').splice(2, 1).join('\n') : 'no stack available :('; }; const newTest = (testObj: ITestObject): void => { @@ -247,7 +242,7 @@ async function testIt(modeHandler: ModeHandler, testObj: ITestObject): Promise'); // Insert all the text as a single action. - await modeHandler.vimState.editor.edit(builder => { + await modeHandler.vimState.editor.edit((builder) => { builder.insert(new Position(0, 0), testObj.start.join('\n').replace('|', '')); }); @@ -300,15 +295,15 @@ async function testIt(modeHandler: ModeHandler, testObj: ITestObject): Promise lines[j.position.line] || ''), - testObj.jumps.map(t => t.replace('|', '')), + jumpTracker.jumps.map((j) => lines[j.position.line] || ''), + testObj.jumps.map((t) => t.replace('|', '')), 'Incorrect jumps found' ); const stripBar = (text: string | undefined) => (text ? text.replace('|', '') : text); const actualJumpPosition = (jumpTracker.currentJump && lines[jumpTracker.currentJump.position.line]) || ''; - const expectedJumpPosition = stripBar(testObj.jumps.find(t => t.includes('|'))) || ''; + const expectedJumpPosition = stripBar(testObj.jumps.find((t) => t.includes('|'))) || ''; assert.deepEqual( actualJumpPosition.toString(), diff --git a/test/testUtils.ts b/test/testUtils.ts index 1689fdfa4..def177b50 100644 --- a/test/testUtils.ts +++ b/test/testUtils.ts @@ -174,7 +174,7 @@ export async function waitForTabChange(): Promise { await new Promise((resolve, reject) => { setTimeout(resolve, 500); - const disposer = vscode.window.onDidChangeActiveTextEditor(textEditor => { + const disposer = vscode.window.onDidChangeActiveTextEditor((textEditor) => { disposer.dispose(); resolve(textEditor);