mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-10-03 23:28:07 +03:00
Update dependency prettier to v2 (#4661)
All line endings are now unix-style (\n), and arrow functions always have parentheses around their parameters.
This commit is contained in:
parent
69adc75659
commit
b6d75ca49a
@ -1,5 +1,4 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
"singleQuote": true
|
||||
}
|
||||
|
24
extension.ts
24
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<T>(
|
||||
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<void> {
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
26
gulpfile.js
26
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);
|
||||
});
|
||||
});
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -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": {
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ class CommandEscInsertMode extends BaseCommand {
|
||||
}
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<VimState> {
|
||||
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<VimState> {
|
||||
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);
|
||||
|
@ -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 (
|
||||
|
@ -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);
|
||||
|
@ -136,10 +136,7 @@ class CommandSurroundModeRepeat extends BaseMovement {
|
||||
public async execAction(position: Position, vimState: VimState): Promise<IMovement> {
|
||||
return {
|
||||
start: position.getLineBeginRespectingIndent(),
|
||||
stop: position
|
||||
.getLineEnd()
|
||||
.getLastWordEnd()
|
||||
.getRight(),
|
||||
stop: position.getLineEnd().getLastWordEnd().getRight(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection {
|
||||
vimState.cursorStartPosition = cursorStartPos;
|
||||
}
|
||||
|
||||
ranges = ranges.filter(range => {
|
||||
ranges = ranges.filter((range) => {
|
||||
return !range.failed;
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -34,10 +34,10 @@ export class MarksCommand extends node.CommandBase {
|
||||
async execute(vimState: VimState): Promise<void> {
|
||||
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, {
|
||||
|
@ -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 &&
|
||||
|
@ -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}`);
|
||||
|
@ -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)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
)
|
||||
);
|
||||
|
@ -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.');
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
@ -395,9 +395,9 @@ function overlapSetting(args: {
|
||||
defaultValue: OptionValue;
|
||||
map?: Map<string | number | boolean, string | number | boolean>;
|
||||
}) {
|
||||
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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -125,7 +125,7 @@ export class RemappingValidator implements IConfigurationValidator {
|
||||
private async getCommandMap(): Promise<Map<string, boolean>> {
|
||||
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;
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 <IMark>marks.find(mark => mark.name === markName);
|
||||
return <IMark>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 += '+';
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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 <Esc>, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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),
|
||||
|
@ -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<void> {
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<boolean> {
|
||||
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<boolean> {
|
||||
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<boolean> {
|
||||
return vscode.window.activeTextEditor!.edit(editBuilder => {
|
||||
return vscode.window.activeTextEditor!.edit((editBuilder) => {
|
||||
editBuilder.replace(range, text);
|
||||
});
|
||||
}
|
||||
|
@ -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}`] : [])
|
||||
);
|
||||
|
@ -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))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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 <C-w> can remove word in cmd line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents([':', 'a', 'b', 'c', '-', '1', '2', '3', '<C-w>']);
|
||||
assertStatusBarEqual(':abc-|', 'Failed to remove "123"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':abc|', 'Failed to remove "-"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':|', 'Failed to remove "abc"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':|', 'Failed to remove nothing');
|
||||
});
|
||||
|
||||
test('command <C-w> can remove word in search mode', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(['/', 'a', 'b', 'c', '-', '1', '2', '3', '<C-w>']);
|
||||
assertStatusBarEqual('/abc-|', 'Failed to remove "123"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/abc|', 'Failed to remove "-"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/|', 'Failed to remove "abc"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/|', 'Failed to remove nothing');
|
||||
});
|
||||
|
||||
test('command <C-w> 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',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<C-w>',
|
||||
]);
|
||||
assertStatusBarEqual(':|123', 'Failed to retain the text on the right of the cursor');
|
||||
});
|
||||
|
||||
test('command <C-w> 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',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<C-w>',
|
||||
]);
|
||||
assertStatusBarEqual('/|123', 'Failed to retain the text on the right of the cursor');
|
||||
});
|
||||
|
||||
test('<C-u> deletes from cursor to first character', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<left>', '<left>', '<C-u>']);
|
||||
assertStatusBarEqual(':|yz');
|
||||
});
|
||||
|
||||
test('<C-b> puts cursor at start of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleKeyEvent('<C-b>');
|
||||
assertStatusBarEqual(':|s/abc/xyz');
|
||||
});
|
||||
|
||||
test('<Home> puts cursor at start of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleKeyEvent('<Home>');
|
||||
assertStatusBarEqual(':|s/abc/xyz');
|
||||
});
|
||||
|
||||
test('<C-e> puts cursor at end of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<C-b>', '<C-e>']);
|
||||
assertStatusBarEqual(':s/abc/xyz|');
|
||||
});
|
||||
|
||||
test('<End> puts cursor at end of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Home>', '<End>']);
|
||||
assertStatusBarEqual(':s/abc/xyz|');
|
||||
});
|
||||
|
||||
test('<C-p>/<C-n> 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', '<C-p>']);
|
||||
|
||||
// Going backward - :s/x/y, then :s/a/b
|
||||
assertStatusBarEqual(':s/x/y|');
|
||||
await modeHandler.handleKeyEvent('<C-p>');
|
||||
assertStatusBarEqual(':s/a/b|');
|
||||
|
||||
// Going forward again - :s/x/y, then :w (the one we started typing)
|
||||
await modeHandler.handleKeyEvent('<C-n>');
|
||||
assertStatusBarEqual(':s/x/y|');
|
||||
await modeHandler.handleKeyEvent('<C-n>');
|
||||
|
||||
// TODO: Really, this should be `:w|`. See #4093.
|
||||
assertStatusBarEqual(':|');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word under cursor on command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('iabc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', ':', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual(':abc|', 'Failed to insert word under cursor');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word right of cursor on command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('i::abc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', '0', ':', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual(':abc|', 'Failed to insert word to right of cursor');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word under cursor in search mode', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('iabc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', '/', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual('/abc|', 'Failed to insert word under cursor');
|
||||
});
|
||||
|
||||
test('<C-p> go to previous search string', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('/abc'.split('').concat('<Esc>'));
|
||||
await modeHandler.handleMultipleKeyEvents(['/', '<C-p>']);
|
||||
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 <C-w> can remove word in cmd line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents([':', 'a', 'b', 'c', '-', '1', '2', '3', '<C-w>']);
|
||||
assertStatusBarEqual(':abc-|', 'Failed to remove "123"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':abc|', 'Failed to remove "-"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':|', 'Failed to remove "abc"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual(':|', 'Failed to remove nothing');
|
||||
});
|
||||
|
||||
test('command <C-w> can remove word in search mode', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(['/', 'a', 'b', 'c', '-', '1', '2', '3', '<C-w>']);
|
||||
assertStatusBarEqual('/abc-|', 'Failed to remove "123"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/abc|', 'Failed to remove "-"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/|', 'Failed to remove "abc"');
|
||||
|
||||
await modeHandler.handleKeyEvent('<C-w>');
|
||||
assertStatusBarEqual('/|', 'Failed to remove nothing');
|
||||
});
|
||||
|
||||
test('command <C-w> 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',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<C-w>',
|
||||
]);
|
||||
assertStatusBarEqual(':|123', 'Failed to retain the text on the right of the cursor');
|
||||
});
|
||||
|
||||
test('command <C-w> 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',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<left>',
|
||||
'<C-w>',
|
||||
]);
|
||||
assertStatusBarEqual('/|123', 'Failed to retain the text on the right of the cursor');
|
||||
});
|
||||
|
||||
test('<C-u> deletes from cursor to first character', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<left>', '<left>', '<C-u>']);
|
||||
assertStatusBarEqual(':|yz');
|
||||
});
|
||||
|
||||
test('<C-b> puts cursor at start of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleKeyEvent('<C-b>');
|
||||
assertStatusBarEqual(':|s/abc/xyz');
|
||||
});
|
||||
|
||||
test('<Home> puts cursor at start of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleKeyEvent('<Home>');
|
||||
assertStatusBarEqual(':|s/abc/xyz');
|
||||
});
|
||||
|
||||
test('<C-e> puts cursor at end of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<C-b>', '<C-e>']);
|
||||
assertStatusBarEqual(':s/abc/xyz|');
|
||||
});
|
||||
|
||||
test('<End> puts cursor at end of command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Home>', '<End>']);
|
||||
assertStatusBarEqual(':s/abc/xyz|');
|
||||
});
|
||||
|
||||
test('<C-p>/<C-n> 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', '<C-p>']);
|
||||
|
||||
// Going backward - :s/x/y, then :s/a/b
|
||||
assertStatusBarEqual(':s/x/y|');
|
||||
await modeHandler.handleKeyEvent('<C-p>');
|
||||
assertStatusBarEqual(':s/a/b|');
|
||||
|
||||
// Going forward again - :s/x/y, then :w (the one we started typing)
|
||||
await modeHandler.handleKeyEvent('<C-n>');
|
||||
assertStatusBarEqual(':s/x/y|');
|
||||
await modeHandler.handleKeyEvent('<C-n>');
|
||||
|
||||
// TODO: Really, this should be `:w|`. See #4093.
|
||||
assertStatusBarEqual(':|');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word under cursor on command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('iabc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', ':', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual(':abc|', 'Failed to insert word under cursor');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word right of cursor on command line', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('i::abc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', '0', ':', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual(':abc|', 'Failed to insert word to right of cursor');
|
||||
});
|
||||
|
||||
test('<C-r> <C-w> insert word under cursor in search mode', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('iabc'.split(''));
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', '/', '<C-r>', '<C-w>']);
|
||||
assertStatusBarEqual('/abc|', 'Failed to insert word under cursor');
|
||||
});
|
||||
|
||||
test('<C-p> go to previous search string', async () => {
|
||||
await modeHandler.handleMultipleKeyEvents('/abc'.split('').concat('<Esc>'));
|
||||
await modeHandler.handleMultipleKeyEvents(['/', '<C-p>']);
|
||||
assertStatusBarEqual('/abc|', 'Failed to go to previous search string');
|
||||
});
|
||||
});
|
||||
|
@ -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));
|
||||
});
|
||||
|
||||
|
@ -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('<Esc>');
|
||||
await vimState.editor.edit(builder => {
|
||||
await vimState.editor.edit((builder) => {
|
||||
builder.insert(new Position(0, 0), lines.join('\n'));
|
||||
});
|
||||
await modeHandler.handleMultipleKeyEvents(['<Esc>', 'g', 'g', 'j', 'j', 'A']);
|
||||
|
@ -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(','));
|
||||
});
|
||||
});
|
||||
|
@ -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 = () => <VimState>(<any>sandbox.createStubInstance(VimState));
|
||||
|
||||
|
@ -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, '<CR>')}`,
|
||||
...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'],
|
||||
|
@ -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', () => {
|
||||
|
@ -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<v
|
||||
await modeHandler.handleKeyEvent('<Esc>');
|
||||
|
||||
// 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<v
|
||||
// jumps: check jumps are correct if given
|
||||
if (testObj.jumps !== undefined) {
|
||||
assert.deepEqual(
|
||||
jumpTracker.jumps.map(j => lines[j.position.line] || '<MISSING>'),
|
||||
testObj.jumps.map(t => t.replace('|', '')),
|
||||
jumpTracker.jumps.map((j) => lines[j.position.line] || '<MISSING>'),
|
||||
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]) || '<FRONT>';
|
||||
const expectedJumpPosition = stripBar(testObj.jumps.find(t => t.includes('|'))) || '<FRONT>';
|
||||
const expectedJumpPosition = stripBar(testObj.jumps.find((t) => t.includes('|'))) || '<FRONT>';
|
||||
|
||||
assert.deepEqual(
|
||||
actualJumpPosition.toString(),
|
||||
|
@ -174,7 +174,7 @@ export async function waitForTabChange(): Promise<void> {
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(resolve, 500);
|
||||
|
||||
const disposer = vscode.window.onDidChangeActiveTextEditor(textEditor => {
|
||||
const disposer = vscode.window.onDidChangeActiveTextEditor((textEditor) => {
|
||||
disposer.dispose();
|
||||
|
||||
resolve(textEditor);
|
||||
|
Loading…
Reference in New Issue
Block a user