mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-17 00:00:26 +03:00
Simplify tslint.json by extending tslint:recommended
As a side-effect, our linting just got substantially stricter, and this had to be a pretty wide-reaching change to comply. Sorry if this complicates any merges!
This commit is contained in:
parent
419bb0bdbf
commit
5a2dc0210d
@ -21,12 +21,12 @@ import { SpecialKeys } from './src/util/specialKeys';
|
||||
import { HistoryTracker } from './src/history/historyTracker';
|
||||
|
||||
let extensionContext: vscode.ExtensionContext;
|
||||
let previousActiveEditorId: EditorIdentity | undefined = undefined;
|
||||
let previousActiveEditorId: EditorIdentity | undefined;
|
||||
let lastClosedModeHandler: ModeHandler | null = null;
|
||||
|
||||
interface ICodeKeybinding {
|
||||
after?: string[];
|
||||
commands?: { command: string; args: any[] }[];
|
||||
commands?: Array<{ command: string; args: any[] }>;
|
||||
}
|
||||
|
||||
export async function getAndUpdateModeHandler(
|
||||
@ -39,7 +39,7 @@ export async function getAndUpdateModeHandler(
|
||||
|
||||
const activeEditorId = EditorIdentity.fromEditor(activeTextEditor);
|
||||
|
||||
let [curHandler, isNew] = await ModeHandlerMap.getOrCreate(activeEditorId);
|
||||
const [curHandler, isNew] = await ModeHandlerMap.getOrCreate(activeEditorId);
|
||||
if (isNew) {
|
||||
extensionContext.subscriptions.push(curHandler);
|
||||
}
|
||||
@ -84,7 +84,7 @@ async function loadConfiguration() {
|
||||
logger.debug(`${validatorResults.numErrors} errors found with vim configuration`);
|
||||
|
||||
if (validatorResults.numErrors > 0) {
|
||||
for (let validatorResult of validatorResults.get()) {
|
||||
for (const validatorResult of validatorResults.get()) {
|
||||
switch (validatorResult.level) {
|
||||
case 'error':
|
||||
logger.error(validatorResult.message);
|
||||
@ -194,7 +194,7 @@ export async function activate(context: vscode.ExtensionContext, handleLocal: bo
|
||||
const documents = vscode.workspace.textDocuments;
|
||||
|
||||
// Delete modehandler once all tabs of this document have been closed
|
||||
for (let editorIdentity of ModeHandlerMap.getKeys()) {
|
||||
for (const editorIdentity of ModeHandlerMap.getKeys()) {
|
||||
const modeHandler = ModeHandlerMap.get(editorIdentity);
|
||||
|
||||
let shouldDelete = false;
|
||||
|
@ -15,6 +15,7 @@ import './src/configuration/validators/remappingValidator';
|
||||
import * as vscode from 'vscode';
|
||||
import { activate as activateFunc } from './extensionBase';
|
||||
|
||||
// tslint:disable-next-line: no-var-requires
|
||||
require('setimmediate');
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
|
@ -112,8 +112,8 @@ export abstract class BaseAction {
|
||||
}
|
||||
|
||||
for (let i = 0, j = 0; i < one.length; i++, j++) {
|
||||
const left = one[i],
|
||||
right = two[j];
|
||||
const left = one[i];
|
||||
const right = two[j];
|
||||
|
||||
if (left === '<any>' || right === '<any>') {
|
||||
continue;
|
||||
@ -206,7 +206,7 @@ export abstract class BaseCommand extends BaseAction {
|
||||
* Run the command the number of times VimState wants us to.
|
||||
*/
|
||||
public async execCount(position: Position, vimState: VimState): Promise<void> {
|
||||
let timesToRepeat = this.runsOnceForEachCountPrefix ? vimState.recordedState.count || 1 : 1;
|
||||
const timesToRepeat = this.runsOnceForEachCountPrefix ? vimState.recordedState.count || 1 : 1;
|
||||
|
||||
if (!this.runsOnceForEveryCursor()) {
|
||||
for (let i = 0; i < timesToRepeat; i++) {
|
||||
@ -222,7 +222,7 @@ export abstract class BaseCommand extends BaseAction {
|
||||
return;
|
||||
}
|
||||
|
||||
let resultingCursors: Range[] = [];
|
||||
const resultingCursors: Range[] = [];
|
||||
|
||||
const cursorsToIterateOver = vimState.cursors
|
||||
.map((x) => new Range(x.start, x.stop))
|
||||
@ -265,7 +265,7 @@ export enum KeypressState {
|
||||
/**
|
||||
* Every Vim action will be added here with the @RegisterAction decorator.
|
||||
*/
|
||||
const actionMap = new Map<Mode, Array<{ new (): BaseAction }>>();
|
||||
const actionMap = new Map<Mode, Array<new () => BaseAction>>();
|
||||
|
||||
/**
|
||||
* Gets the action that should be triggered given a key sequence.
|
||||
@ -299,7 +299,7 @@ export function getRelevantAction(
|
||||
return isPotentialMatch ? KeypressState.WaitingOnKeys : KeypressState.NoPossibleMatch;
|
||||
}
|
||||
|
||||
export function RegisterAction(action: { new (): BaseAction }): void {
|
||||
export function RegisterAction(action: new () => BaseAction): void {
|
||||
const actionInstance = new action();
|
||||
for (const modeName of actionInstance.modes) {
|
||||
let actions = actionMap.get(modeName);
|
||||
|
@ -113,7 +113,7 @@ export abstract class BaseMovement extends BaseAction {
|
||||
vimState: VimState,
|
||||
count: number
|
||||
): Promise<Position | IMovement> {
|
||||
let recordedState = vimState.recordedState;
|
||||
const recordedState = vimState.recordedState;
|
||||
let result: Position | IMovement = new Position(0, 0); // bogus init to satisfy typechecker
|
||||
let prevResult = failedMovement(vimState);
|
||||
let firstMovementStart: Position = new Position(position.line, position.character);
|
||||
|
@ -153,7 +153,7 @@ export class DocumentContentChangeAction extends BaseAction {
|
||||
};
|
||||
}
|
||||
|
||||
let compressed: vscode.TextDocumentContentChangeEvent[] = [];
|
||||
const compressed: vscode.TextDocumentContentChangeEvent[] = [];
|
||||
let prev: vscode.TextDocumentContentChangeEvent | undefined;
|
||||
for (const change of this.contentChanges) {
|
||||
if (prev === undefined) {
|
||||
@ -217,7 +217,7 @@ export class CommandNumber extends BaseCommand {
|
||||
}
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
const number = parseInt(this.keysPressed[0], 10);
|
||||
const num = parseInt(this.keysPressed[0], 10);
|
||||
const operatorCount = vimState.recordedState.operatorCount;
|
||||
|
||||
if (operatorCount > 0) {
|
||||
@ -226,7 +226,7 @@ export class CommandNumber extends BaseCommand {
|
||||
if (!(lastAction instanceof CommandNumber)) {
|
||||
// We have set an operatorCount !== 0 after an operator, but now we got another count
|
||||
// number so we need to multiply them.
|
||||
vimState.recordedState.count = operatorCount * number;
|
||||
vimState.recordedState.count = operatorCount * num;
|
||||
} else {
|
||||
// We are now getting another digit which means we need to multiply by 10 and add
|
||||
// the new digit multiplied by operatorCount.
|
||||
@ -238,10 +238,10 @@ export class CommandNumber extends BaseCommand {
|
||||
// - After '1' the count is multiplied by 10 and added by number 1 multiplied by 'operatorCount'
|
||||
// (6 * 10 + 1 * 2 = 62)
|
||||
// The final result will be the deletion of 62 words.
|
||||
vimState.recordedState.count = vimState.recordedState.count * 10 + number * operatorCount;
|
||||
vimState.recordedState.count = vimState.recordedState.count * 10 + num * operatorCount;
|
||||
}
|
||||
} else {
|
||||
vimState.recordedState.count = vimState.recordedState.count * 10 + number;
|
||||
vimState.recordedState.count = vimState.recordedState.count * 10 + num;
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ class CommandRecordMacro extends BaseCommand {
|
||||
|
||||
if (!/^[A-Z]+$/.test(registerKey) || !Register.has(register)) {
|
||||
// If register name is upper case, it means we are appending commands to existing register instead of overriding.
|
||||
let newRegister = new RecordedState();
|
||||
const newRegister = new RecordedState();
|
||||
newRegister.registerName = register;
|
||||
Register.putByKey(newRegister, register);
|
||||
}
|
||||
@ -343,7 +343,7 @@ class CommandExecuteMacro extends BaseCommand {
|
||||
if (Register.has(register)) {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'macro',
|
||||
register: register,
|
||||
register,
|
||||
replay: 'contentChange',
|
||||
});
|
||||
}
|
||||
@ -453,7 +453,7 @@ class CommandEscReplaceMode extends BaseCommand {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'insertText',
|
||||
text: textToAdd,
|
||||
position: position,
|
||||
position,
|
||||
diff: new PositionDiff({ character: -1 }),
|
||||
});
|
||||
|
||||
@ -665,7 +665,7 @@ export class CommandReplaceAtCursorFromNormalMode extends BaseCommand {
|
||||
keys = ['R'];
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
let timesToRepeat = vimState.recordedState.count || 1;
|
||||
const timesToRepeat = vimState.recordedState.count || 1;
|
||||
|
||||
await vimState.setCurrentMode(Mode.Replace);
|
||||
vimState.replaceState = new ReplaceState(vimState, position, timesToRepeat);
|
||||
@ -695,7 +695,7 @@ class CommandReplaceInReplaceMode extends BaseCommand {
|
||||
) {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'deleteText',
|
||||
position: position,
|
||||
position,
|
||||
});
|
||||
} else {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
@ -719,7 +719,7 @@ class CommandReplaceInReplaceMode extends BaseCommand {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'insertText',
|
||||
text: char,
|
||||
position: position,
|
||||
position,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1166,7 +1166,7 @@ class CommandDot extends BaseCommand {
|
||||
keys = ['.'];
|
||||
|
||||
public async execCount(position: Position, vimState: VimState): Promise<void> {
|
||||
let count = vimState.recordedState.count || 1;
|
||||
const count = vimState.recordedState.count || 1;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
@ -1800,7 +1800,7 @@ class CommandOpenFile extends BaseCommand {
|
||||
const lineNumber = parseInt(fileInfo[2], 10);
|
||||
const fileCommand = new FileCommand({
|
||||
name: filePath,
|
||||
lineNumber: lineNumber,
|
||||
lineNumber,
|
||||
createFileIfNotExists: false,
|
||||
});
|
||||
fileCommand.execute(vimState);
|
||||
@ -2006,7 +2006,7 @@ class CommandInsertNewLineAbove extends BaseCommand {
|
||||
|
||||
public async execCount(position: Position, vimState: VimState): Promise<void> {
|
||||
await vimState.setCurrentMode(Mode.Insert);
|
||||
let count = vimState.recordedState.count || 1;
|
||||
const count = vimState.recordedState.count || 1;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
await vscode.commands.executeCommand('editor.action.insertLineBefore');
|
||||
@ -2036,7 +2036,7 @@ class CommandInsertNewLineBefore extends BaseCommand {
|
||||
|
||||
public async execCount(position: Position, vimState: VimState): Promise<void> {
|
||||
await vimState.setCurrentMode(Mode.Insert);
|
||||
let count = vimState.recordedState.count || 1;
|
||||
const count = vimState.recordedState.count || 1;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
await vscode.commands.executeCommand('editor.action.insertLineAfter');
|
||||
@ -2326,7 +2326,7 @@ export class ActionDeleteChar extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
let timesToRepeat = vimState.recordedState.count || 1;
|
||||
const timesToRepeat = vimState.recordedState.count || 1;
|
||||
|
||||
await new operator.DeleteOperator(this.multicursorIndex).run(
|
||||
vimState,
|
||||
@ -2373,7 +2373,7 @@ export class ActionDeleteLastChar extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
let timesToRepeat = vimState.recordedState.count || 1;
|
||||
const timesToRepeat = vimState.recordedState.count || 1;
|
||||
|
||||
await new operator.DeleteOperator(this.multicursorIndex).run(
|
||||
vimState,
|
||||
@ -2392,7 +2392,7 @@ class ActionJoin extends BaseCommand {
|
||||
|
||||
private firstNonWhitespaceIndex(str: string): number {
|
||||
for (let i = 0, len = str.length; i < len; i++) {
|
||||
let chCode = str.charCodeAt(i);
|
||||
const chCode = str.charCodeAt(i);
|
||||
if (chCode !== 32 /** space */ && chCode !== 9 /** tab */) {
|
||||
return i;
|
||||
}
|
||||
@ -2408,11 +2408,11 @@ class ActionJoin extends BaseCommand {
|
||||
): Promise<void> {
|
||||
count = count - 1 || 1;
|
||||
|
||||
let startLineNumber: number,
|
||||
startColumn: number,
|
||||
endLineNumber: number,
|
||||
endColumn: number,
|
||||
columnDeltaOffset: number = 0;
|
||||
let startLineNumber: number;
|
||||
let startColumn: number;
|
||||
let endLineNumber: number;
|
||||
let endColumn: number;
|
||||
let columnDeltaOffset: number = 0;
|
||||
|
||||
if (startPosition.isEqual(position) || startPosition.line === position.line) {
|
||||
if (position.line + 1 < vimState.document.lineCount) {
|
||||
@ -2438,7 +2438,7 @@ class ActionJoin extends BaseCommand {
|
||||
for (let i = startLineNumber + 1; i <= endLineNumber; i++) {
|
||||
const lineText = vimState.document.lineAt(i).text;
|
||||
|
||||
let firstNonWhitespaceIdx = this.firstNonWhitespaceIndex(lineText);
|
||||
const firstNonWhitespaceIdx = this.firstNonWhitespaceIndex(lineText);
|
||||
|
||||
if (firstNonWhitespaceIdx >= 0) {
|
||||
let insertSpace = true;
|
||||
@ -2451,7 +2451,7 @@ class ActionJoin extends BaseCommand {
|
||||
insertSpace = false;
|
||||
}
|
||||
|
||||
let lineTextWithoutIndent = lineText.substr(firstNonWhitespaceIdx);
|
||||
const lineTextWithoutIndent = lineText.substr(firstNonWhitespaceIdx);
|
||||
|
||||
if (lineTextWithoutIndent.charAt(0) === ')') {
|
||||
insertSpace = false;
|
||||
@ -2476,8 +2476,8 @@ class ActionJoin extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
let deleteStartPosition = new Position(startLineNumber, startColumn);
|
||||
let deleteEndPosition = new Position(endLineNumber, endColumn);
|
||||
const deleteStartPosition = new Position(startLineNumber, startColumn);
|
||||
const deleteEndPosition = new Position(endLineNumber, endColumn);
|
||||
|
||||
if (!deleteStartPosition.isEqual(deleteEndPosition)) {
|
||||
if (startPosition.isEqual(position)) {
|
||||
@ -2516,7 +2516,7 @@ class ActionJoin extends BaseCommand {
|
||||
: -1
|
||||
);
|
||||
|
||||
let resultingCursors: Range[] = [];
|
||||
const resultingCursors: Range[] = [];
|
||||
for (const [idx, { start, stop }] of cursorsToIterateOver.entries()) {
|
||||
this.multicursorIndex = idx;
|
||||
|
||||
@ -2604,7 +2604,7 @@ class ActionJoinNoWhitespace extends BaseCommand {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'insertText',
|
||||
text: resultLine,
|
||||
position: position,
|
||||
position,
|
||||
diff: new PositionDiff({
|
||||
character: -lastLineLength,
|
||||
}),
|
||||
@ -2635,7 +2635,7 @@ class ActionReplaceCharacter extends BaseCommand {
|
||||
runsOnceForEachCountPrefix = false;
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
let timesToRepeat = vimState.recordedState.count || 1;
|
||||
const timesToRepeat = vimState.recordedState.count || 1;
|
||||
const toReplace = this.keysPressed[1];
|
||||
|
||||
/**
|
||||
@ -2979,7 +2979,7 @@ abstract class ActionGoToInsertVisualLineModeCommand extends BaseCommand {
|
||||
const resultingCursors: Range[] = [];
|
||||
const cursorsOnBlankLines: Range[] = [];
|
||||
for (const selection of vimState.editor.selections) {
|
||||
let { start, end } = selection;
|
||||
const { start, end } = selection;
|
||||
|
||||
for (let i = start.line; i <= end.line; i++) {
|
||||
const line = vimState.document.lineAt(i);
|
||||
@ -3323,7 +3323,7 @@ abstract class IncrementDecrementNumberAction extends BaseCommand {
|
||||
* @returns a list of Ranges in which to search for numbers
|
||||
*/
|
||||
private getSearchRanges(vimState: VimState): Range[] {
|
||||
let ranges: Range[] = [];
|
||||
const ranges: Range[] = [];
|
||||
const [start, stop] = sorted(vimState.cursorStartPosition, vimState.cursorStopPosition);
|
||||
switch (vimState.currentMode) {
|
||||
case Mode.Normal: {
|
||||
|
@ -75,7 +75,7 @@ class CommandTabInCommandline extends BaseCommand {
|
||||
|
||||
// Sub string since vim does completion before the cursor
|
||||
let evalCmd = currentCmd.slice(0, cursorPos);
|
||||
let restCmd = currentCmd.slice(cursorPos);
|
||||
const restCmd = currentCmd.slice(cursorPos);
|
||||
|
||||
// \s* is the match the extra space before any character like ': edit'
|
||||
const cmdRegex = /^\s*\w+$/;
|
||||
@ -90,7 +90,7 @@ class CommandTabInCommandline extends BaseCommand {
|
||||
} else if (fileRegex.exec(evalCmd)) {
|
||||
// File completion by searching if there is a space after the first word/command
|
||||
// ideally it should be a process of white-listing to selected commands like :e and :vsp
|
||||
let filePathInCmd = evalCmd.substring(fileRegex.lastIndex);
|
||||
const filePathInCmd = evalCmd.substring(fileRegex.lastIndex);
|
||||
const currentUri = vimState.document.uri;
|
||||
const isRemote = !!vscode.env.remoteName;
|
||||
|
||||
@ -285,7 +285,7 @@ class CommandInsertInCommandline extends BaseCommand {
|
||||
|
||||
vimState.statusBarCursorCharacterPos = vimState.currentCommandlineText.length;
|
||||
} else {
|
||||
let modifiedString = vimState.currentCommandlineText.split('');
|
||||
const modifiedString = vimState.currentCommandlineText.split('');
|
||||
modifiedString.splice(vimState.statusBarCursorCharacterPos, 0, key);
|
||||
vimState.currentCommandlineText = modifiedString.join('');
|
||||
vimState.statusBarCursorCharacterPos += key.length;
|
||||
@ -436,7 +436,7 @@ class CommandInsertInSearchMode extends BaseCommand {
|
||||
}
|
||||
vimState.statusBarCursorCharacterPos = searchState.searchString.length;
|
||||
} else {
|
||||
let modifiedString = searchState.searchString.split('');
|
||||
const modifiedString = searchState.searchString.split('');
|
||||
modifiedString.splice(vimState.statusBarCursorCharacterPos, 0, key);
|
||||
searchState.searchString = modifiedString.join('');
|
||||
vimState.statusBarCursorCharacterPos += key.length;
|
||||
@ -517,7 +517,7 @@ class CommandInsertRegisterContentInCommandLine extends BaseCommand {
|
||||
} else if (register.text instanceof RecordedState) {
|
||||
let keyStrokes: string[] = [];
|
||||
|
||||
for (let action of register.text.actionsRun) {
|
||||
for (const action of register.text.actionsRun) {
|
||||
keyStrokes = keyStrokes.concat(action.keysPressed);
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ class CommandInsertRegisterContentInSearchMode extends BaseCommand {
|
||||
} else if (register.text instanceof RecordedState) {
|
||||
let keyStrokes: string[] = [];
|
||||
|
||||
for (let action of register.text.actionsRun) {
|
||||
for (const action of register.text.actionsRun) {
|
||||
keyStrokes = keyStrokes.concat(action.keysPressed);
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ class CommandNavigateInCommandlineOrSearchMode extends BaseCommand {
|
||||
private getTrimmedStatusBarText() {
|
||||
// first regex removes the : / and | from the string
|
||||
// second regex removes a single space from the end of the string
|
||||
let trimmedStatusBarText = StatusBar.getText()
|
||||
const trimmedStatusBarText = StatusBar.getText()
|
||||
.replace(/^(?:\/|\:)(.*)(?:\|)(.*)/, '$1$2')
|
||||
.replace(/(.*) $/, '$1');
|
||||
return trimmedStatusBarText;
|
||||
@ -622,7 +622,7 @@ class CommandNavigateInCommandlineOrSearchMode extends BaseCommand {
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
const key = this.keysPressed[0];
|
||||
let statusBarText = this.getTrimmedStatusBarText();
|
||||
const statusBarText = this.getTrimmedStatusBarText();
|
||||
if (key === '<right>') {
|
||||
vimState.statusBarCursorCharacterPos = Math.min(
|
||||
vimState.statusBarCursorCharacterPos + 1,
|
||||
|
@ -138,7 +138,7 @@ export class CommandInsertPreviousText extends BaseCommand {
|
||||
actions.shift();
|
||||
}
|
||||
|
||||
for (let action of actions) {
|
||||
for (const action of actions) {
|
||||
if (action instanceof BaseCommand) {
|
||||
await action.execCount(vimState.cursorStopPosition, vimState);
|
||||
}
|
||||
@ -265,7 +265,7 @@ export class CommandBackspaceInInsertMode extends BaseCommand {
|
||||
// Otherwise, just delete a character (unless we're at the start of the document)
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'deleteText',
|
||||
position: position,
|
||||
position,
|
||||
});
|
||||
}
|
||||
|
||||
@ -414,8 +414,8 @@ class CommandInsertRegisterContent extends BaseCommand {
|
||||
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'insertText',
|
||||
text: text,
|
||||
position: position,
|
||||
text,
|
||||
position,
|
||||
});
|
||||
await vimState.setCurrentMode(Mode.Insert);
|
||||
vimState.cursorStartPosition = vimState.editor.selection.start;
|
||||
@ -646,7 +646,7 @@ class NewLineInsertMode extends BaseCommand {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'insertText',
|
||||
text: '\n',
|
||||
position: position,
|
||||
position,
|
||||
diff: new PositionDiff({ character: -1 }),
|
||||
});
|
||||
}
|
||||
|
@ -143,16 +143,16 @@ export class PutCommand extends BaseCommand {
|
||||
} else {
|
||||
if (options.adjustIndent) {
|
||||
// Adjust indent to current line
|
||||
let indentationWidth = TextEditor.getIndentationLevel(
|
||||
const indentationWidth = TextEditor.getIndentationLevel(
|
||||
vimState.document.lineAt(position).text
|
||||
);
|
||||
let firstLineIdentationWidth = TextEditor.getIndentationLevel(text.split('\n')[0]);
|
||||
const firstLineIdentationWidth = TextEditor.getIndentationLevel(text.split('\n')[0]);
|
||||
|
||||
text = text
|
||||
.split('\n')
|
||||
.map((line) => {
|
||||
let currentIdentationWidth = TextEditor.getIndentationLevel(line);
|
||||
let newIndentationWidth =
|
||||
const currentIdentationWidth = TextEditor.getIndentationLevel(line);
|
||||
const newIndentationWidth =
|
||||
currentIdentationWidth - firstLineIdentationWidth + indentationWidth;
|
||||
|
||||
return TextEditor.setIndentationLevel(line, newIndentationWidth);
|
||||
@ -211,7 +211,7 @@ export class PutCommand extends BaseCommand {
|
||||
};
|
||||
} else if (registerMode === RegisterMode.LineWise && options.forceCursorLastLine) {
|
||||
// Move to cursor to last line, first non-whitespace character of what you pasted
|
||||
let lastLine = text.split('\n')[numNewlines];
|
||||
const lastLine = text.split('\n')[numNewlines];
|
||||
const check = lastLine.match(/^\s*/);
|
||||
const numWhitespace = check ? check[0].length : 0;
|
||||
|
||||
@ -280,7 +280,7 @@ export class PutCommand extends BaseCommand {
|
||||
type: 'insertText',
|
||||
text: textToAdd,
|
||||
position: whereToAddText,
|
||||
diff: diff,
|
||||
diff,
|
||||
});
|
||||
let numNewlinesAfterPut = textToAdd.split('\n').length;
|
||||
if (registerMode === RegisterMode.LineWise) {
|
||||
@ -407,7 +407,7 @@ class PutCommandVisual extends BaseCommand {
|
||||
// To ensure that the put command knows this is
|
||||
// a linewise register insertion in visual mode of
|
||||
// characterwise, linewise
|
||||
let resultMode = vimState.currentMode;
|
||||
const resultMode = vimState.currentMode;
|
||||
await vimState.setCurrentMode(oldMode);
|
||||
vimState.recordedState.registerName = replaceRegisterName;
|
||||
await new PutCommand(this.multicursorIndex).exec(start, vimState, {
|
||||
@ -530,7 +530,7 @@ class GPutCommandVisualLine extends PutCommandVisualLine {
|
||||
];
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
let repeats = vimState.recordedState.count === 0 ? 1 : vimState.recordedState.count;
|
||||
const repeats = vimState.recordedState.count === 0 ? 1 : vimState.recordedState.count;
|
||||
await super.exec(position, vimState);
|
||||
// Vgp should place the cursor on the next line
|
||||
if (vimState.effectiveRegisterMode === RegisterMode.LineWise) {
|
||||
|
@ -61,7 +61,7 @@ abstract class MoveByScreenLine extends BaseMovement {
|
||||
// If we change the `vimState.editor.selections` directly with the forEach
|
||||
// for some reason vscode doesn't update them. But doing it this way does
|
||||
// update vscode's selections.
|
||||
let selections = vimState.editor.selections;
|
||||
const selections = vimState.editor.selections;
|
||||
selections.forEach((s, i) => {
|
||||
if (s.active.isAfter(s.anchor)) {
|
||||
// The selection is on the right side of the cursor, while our representation
|
||||
@ -103,7 +103,7 @@ abstract class MoveByScreenLine extends BaseMovement {
|
||||
}
|
||||
|
||||
let start = vimState.editor.selections[multicursorIndex].anchor;
|
||||
let stop = vimState.editor.selections[multicursorIndex].active;
|
||||
const stop = vimState.editor.selections[multicursorIndex].active;
|
||||
|
||||
// If we are moving up we need to keep getting the left of anchor/start because vscode is
|
||||
// to the right of the character in order to include it but our positions are always on the
|
||||
@ -171,8 +171,8 @@ abstract class MoveByScreenLineMaintainDesiredColumn extends MoveByScreenLine {
|
||||
return true;
|
||||
}
|
||||
public async execAction(position: Position, vimState: VimState): Promise<Position | IMovement> {
|
||||
let prevDesiredColumn = vimState.desiredColumn;
|
||||
let prevLine = vimState.editor.selection.active.line;
|
||||
const prevDesiredColumn = vimState.desiredColumn;
|
||||
const prevLine = vimState.editor.selection.active.line;
|
||||
|
||||
if (vimState.currentMode !== Mode.Normal) {
|
||||
/**
|
||||
@ -180,7 +180,7 @@ abstract class MoveByScreenLineMaintainDesiredColumn extends MoveByScreenLine {
|
||||
* differently we need to sometimes move the cursor at the end
|
||||
* of the selection back by a character.
|
||||
*/
|
||||
let start = vimState.editor.selection.start;
|
||||
const start = vimState.editor.selection.start;
|
||||
if (
|
||||
(this.movementType === 'down' && position.line > start.line) ||
|
||||
(this.movementType === 'up' && position.line < prevLine)
|
||||
@ -214,7 +214,7 @@ abstract class MoveByScreenLineMaintainDesiredColumn extends MoveByScreenLine {
|
||||
*/
|
||||
let start = vimState.editor.selection.start;
|
||||
let stop = vimState.editor.selection.end;
|
||||
let curPos = vimState.editor.selection.active;
|
||||
const curPos = vimState.editor.selection.active;
|
||||
|
||||
// We want to swap the cursor start stop positions based on which direction we are moving, up or down
|
||||
if (start.isEqual(curPos) && !start.isEqual(stop)) {
|
||||
@ -762,7 +762,7 @@ class MoveFindBackward extends BaseMovement {
|
||||
|
||||
count ||= 1;
|
||||
const toFind = Notation.ToControlCharacter(this.keysPressed[1]);
|
||||
let result = findHelper(vimState, position, toFind, count, 'backward');
|
||||
const result = findHelper(vimState, position, toFind, count, 'backward');
|
||||
|
||||
vimState.lastSemicolonRepeatableMovement = new MoveFindBackward(this.keysPressed, true);
|
||||
vimState.lastCommaRepeatableMovement = new MoveFindForward(this.keysPressed, true);
|
||||
@ -1237,7 +1237,7 @@ class MoveNonBlankLast extends BaseMovement {
|
||||
|
||||
return {
|
||||
start: vimState.cursorStartPosition,
|
||||
stop: stop,
|
||||
stop,
|
||||
registerMode: RegisterMode.LineWise,
|
||||
};
|
||||
}
|
||||
@ -1337,7 +1337,7 @@ class MoveWordEnd extends BaseMovement {
|
||||
}
|
||||
|
||||
public async execActionForOperator(position: Position, vimState: VimState): Promise<Position> {
|
||||
let end = position.getCurrentWordEnd();
|
||||
const end = position.getCurrentWordEnd();
|
||||
|
||||
return new Position(end.line, end.character + 1);
|
||||
}
|
||||
@ -1983,7 +1983,7 @@ abstract class MoveTagMatch extends ExpandingSelection {
|
||||
return failedMovement(vimState);
|
||||
}
|
||||
|
||||
let startPosition =
|
||||
const startPosition =
|
||||
start >= 0 ? vimState.document.positionAt(start) : vimState.cursorStartPosition;
|
||||
let endPosition = end >= 0 ? vimState.document.positionAt(end) : position;
|
||||
if (vimState.currentMode === Mode.Visual || vimState.currentMode === Mode.SurroundInputMode) {
|
||||
|
@ -8,7 +8,7 @@ import { Register, RegisterMode } from './../register/register';
|
||||
import { VimState } from './../state/vimState';
|
||||
import { TextEditor } from './../textEditor';
|
||||
import { BaseAction, RegisterAction } from './base';
|
||||
import { CommandNumber, DocumentContentChangeAction } from './commands/actions';
|
||||
import { CommandNumber } from './commands/actions';
|
||||
import { TextObjectMovement } from '../textobject/textobject';
|
||||
import { reportLinesChanged, reportLinesYanked } from '../util/statusBarTextUtils';
|
||||
import { commandLine } from './../cmd_line/commandLine';
|
||||
@ -201,14 +201,14 @@ export class DeleteOperator extends BaseOperator {
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'deleteRange',
|
||||
range: new Range(start, end),
|
||||
diff: diff,
|
||||
diff,
|
||||
});
|
||||
|
||||
return resultingPosition;
|
||||
}
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position, yank = true): Promise<void> {
|
||||
let newPos = await this.delete(
|
||||
const newPos = await this.delete(
|
||||
start,
|
||||
end,
|
||||
vimState.currentMode,
|
||||
@ -403,7 +403,7 @@ export class FormatOperator extends BaseOperator {
|
||||
line = vimState.cursorStopPosition.line;
|
||||
}
|
||||
|
||||
let newCursorPosition = TextEditor.getFirstNonWhitespaceCharOnLine(vimState.document, line);
|
||||
const newCursorPosition = TextEditor.getFirstNonWhitespaceCharOnLine(vimState.document, line);
|
||||
vimState.cursorStopPosition = newCursorPosition;
|
||||
vimState.cursorStartPosition = newCursorPosition;
|
||||
await vimState.setCurrentMode(Mode.Normal);
|
||||
@ -417,7 +417,7 @@ export class UpperCaseOperator extends BaseOperator {
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position): Promise<void> {
|
||||
const range = new vscode.Range(start, new Position(end.line, end.character + 1));
|
||||
let text = vimState.document.getText(range);
|
||||
const text = vimState.document.getText(range);
|
||||
|
||||
await TextEditor.replace(vimState.editor, range, text.toUpperCase());
|
||||
|
||||
@ -440,7 +440,7 @@ class UpperCaseVisualBlockOperator extends BaseOperator {
|
||||
public async run(vimState: VimState, startPos: Position, endPos: Position): Promise<void> {
|
||||
for (const { start, end } of TextEditor.iterateLinesInBlock(vimState)) {
|
||||
const range = new vscode.Range(start, end);
|
||||
let text = vimState.document.getText(range);
|
||||
const text = vimState.document.getText(range);
|
||||
await TextEditor.replace(vimState.editor, range, text.toUpperCase());
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ export class LowerCaseOperator extends BaseOperator {
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position): Promise<void> {
|
||||
const range = new vscode.Range(start, new Position(end.line, end.character + 1));
|
||||
let text = vimState.document.getText(range);
|
||||
const text = vimState.document.getText(range);
|
||||
|
||||
await TextEditor.replace(vimState.editor, range, text.toLowerCase());
|
||||
|
||||
@ -481,7 +481,7 @@ class LowerCaseVisualBlockOperator extends BaseOperator {
|
||||
public async run(vimState: VimState, startPos: Position, endPos: Position): Promise<void> {
|
||||
for (const { start, end } of TextEditor.iterateLinesInBlock(vimState)) {
|
||||
const range = new vscode.Range(start, end);
|
||||
let text = vimState.document.getText(range);
|
||||
const text = vimState.document.getText(range);
|
||||
await TextEditor.replace(vimState.editor, range, text.toLowerCase());
|
||||
}
|
||||
|
||||
@ -922,7 +922,7 @@ class ActionVisualReflowParagraph extends BaseOperator {
|
||||
indentLevelAfterComment: number;
|
||||
final: boolean;
|
||||
}
|
||||
let chunksToReflow: Chunk[] = [];
|
||||
const chunksToReflow: Chunk[] = [];
|
||||
|
||||
for (const line of s.split('\n')) {
|
||||
let lastChunk: Chunk | undefined = chunksToReflow[chunksToReflow.length - 1];
|
||||
@ -966,7 +966,7 @@ class ActionVisualReflowParagraph extends BaseOperator {
|
||||
|
||||
// Did they start a new comment type?
|
||||
if (!lastChunk || lastChunk.final || commentType.start !== lastChunk.commentType.start) {
|
||||
let chunk = {
|
||||
const chunk = {
|
||||
commentType,
|
||||
content: `${trimmedLine.substr(commentType.start.length).trim()}`,
|
||||
indentLevelAfterComment: 0,
|
||||
@ -1013,7 +1013,7 @@ class ActionVisualReflowParagraph extends BaseOperator {
|
||||
}
|
||||
|
||||
// Reflow each chunk.
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
|
||||
for (const { commentType, content, indentLevelAfterComment } of chunksToReflow) {
|
||||
let lines: string[];
|
||||
|
@ -65,7 +65,7 @@ class MoveCamelCaseWordEnd extends CamelCaseBaseMovement {
|
||||
}
|
||||
|
||||
public async execActionForOperator(position: Position, vimState: VimState): Promise<Position> {
|
||||
let end = getCurrentWordEnd(position, WordType.CamelCase);
|
||||
const end = getCurrentWordEnd(position, WordType.CamelCase);
|
||||
|
||||
return new Position(end.line, end.character + 1);
|
||||
}
|
||||
@ -117,8 +117,8 @@ class SelectInnerCamelCaseWord extends CamelCaseTextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ export class EasyMotion {
|
||||
const firstCharRenderOptions: vscode.ThemableDecorationInstanceRenderOptions = {
|
||||
before: {
|
||||
contentText: keystroke.substring(0, 1),
|
||||
backgroundColor: backgroundColor,
|
||||
backgroundColor,
|
||||
color: firstCharFontColor,
|
||||
margin: `0 -1ch 0 0;
|
||||
position: absolute;
|
||||
@ -329,7 +329,7 @@ export class EasyMotion {
|
||||
const secondCharRenderOptions: vscode.ThemableDecorationInstanceRenderOptions = {
|
||||
before: {
|
||||
contentText: keystroke.slice(1),
|
||||
backgroundColor: backgroundColor,
|
||||
backgroundColor,
|
||||
color: secondCharFontColor,
|
||||
margin: `0 -1ch 0 0;
|
||||
position: absolute;
|
||||
|
@ -39,8 +39,8 @@ export class InputMethodSwitcher {
|
||||
return;
|
||||
}
|
||||
// when you exit from insert-like mode, save origin input method and set it to default
|
||||
let isPrevModeInsertLike = this.isInsertLikeMode(prevMode);
|
||||
let isNewModeInsertLike = this.isInsertLikeMode(newMode);
|
||||
const isPrevModeInsertLike = this.isInsertLikeMode(prevMode);
|
||||
const isNewModeInsertLike = this.isInsertLikeMode(newMode);
|
||||
if (isPrevModeInsertLike !== isNewModeInsertLike) {
|
||||
if (isNewModeInsertLike) {
|
||||
await this.resumeIM();
|
||||
|
@ -362,7 +362,7 @@ class CommandSurroundAddToReplacement extends BaseCommand {
|
||||
let endReplace = replacement;
|
||||
|
||||
if (startReplace[0] === '<') {
|
||||
let tagName = /([-\w.]+)/.exec(startReplace);
|
||||
const tagName = /([-\w.]+)/.exec(startReplace);
|
||||
if (tagName) {
|
||||
endReplace = `</${tagName[1]}>`;
|
||||
} else {
|
||||
@ -501,8 +501,8 @@ class CommandSurroundAddToReplacement extends BaseCommand {
|
||||
if (target === 't') {
|
||||
// `MoveInsideTag` must be run first as otherwise the search will
|
||||
// look for the next enclosing tag after having selected the first
|
||||
let innerTagContent = await new MoveInsideTag().execAction(position, vimState);
|
||||
let { start, stop, failed } = await new MoveAroundTag().execAction(position, vimState);
|
||||
const innerTagContent = await new MoveInsideTag().execAction(position, vimState);
|
||||
const { start, stop, failed } = await new MoveAroundTag().execAction(position, vimState);
|
||||
|
||||
if (failed || innerTagContent.failed) {
|
||||
return CommandSurroundAddToReplacement.finish(vimState);
|
||||
@ -520,7 +520,7 @@ class CommandSurroundAddToReplacement extends BaseCommand {
|
||||
// Special case: 'change' with targets w(ord), W(ord), s(entence), p(aragraph)
|
||||
// is a shortcut for 'yank' with an inner text object (e.g. `csw]` is the same as `ysiw]`)
|
||||
if (operator === 'change') {
|
||||
let textObj: { new (): TextObjectMovement } | undefined;
|
||||
let textObj: (new () => TextObjectMovement) | undefined;
|
||||
let addNewline: 'no' | 'end-only' | 'both' = 'no';
|
||||
if (target === 'w') {
|
||||
[textObj, addNewline] = [SelectInnerWord, 'no'];
|
||||
|
@ -53,7 +53,7 @@ class CommandLine {
|
||||
this.commandLineHistoryIndex = this._history.get().length;
|
||||
|
||||
if (!command.startsWith('reg')) {
|
||||
let recState = new RecordedState();
|
||||
const recState = new RecordedState();
|
||||
recState.registerName = ':';
|
||||
recState.commandList = command.split('');
|
||||
Register.putByKey(recState, ':', undefined, true);
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { TextEditor } from '../../textEditor';
|
||||
|
||||
import * as node from '../node';
|
||||
import { VimState } from '../../state/vimState';
|
||||
@ -57,7 +56,7 @@ export class BangCommand extends node.CommandBase {
|
||||
type: 'replaceText',
|
||||
text: output,
|
||||
range: new Range(start, end),
|
||||
diff: diff,
|
||||
diff,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class CloseCommand extends node.CommandBase {
|
||||
throw error.VimError.fromCode(error.ErrorCode.CannotCloseLastWindow);
|
||||
}
|
||||
|
||||
let oldViewColumn = vimState.editor.viewColumn;
|
||||
const oldViewColumn = vimState.editor.viewColumn;
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
||||
if (
|
||||
|
@ -69,7 +69,7 @@ export class DeleteRangeCommand extends node.CommandBase {
|
||||
async executeWithRange(vimState: VimState, range: node.LineRange): Promise<void> {
|
||||
const [start, end] = range.resolve(vimState);
|
||||
|
||||
let text = await this.deleteRange(start, end, vimState);
|
||||
const text = await this.deleteRange(start, end, vimState);
|
||||
const register = this._arguments.register ?? (configuration.useSystemClipboard ? '*' : '"');
|
||||
Register.putByKey(text, register, RegisterMode.LineWise);
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ export class DigraphsCommand extends node.CommandBase {
|
||||
}
|
||||
|
||||
// TODO: replace 'any' with sensible index signature
|
||||
private makeQuickPicks(digraphs: any): Array<DigraphQuickPickItem> {
|
||||
private makeQuickPicks(digraphs: any): DigraphQuickPickItem[] {
|
||||
const quickPicks = new Array<DigraphQuickPickItem>();
|
||||
for (let digraphKey of Object.keys(digraphs)) {
|
||||
let [charDesc, charCodes] = digraphs[digraphKey];
|
||||
for (const digraphKey of Object.keys(digraphs)) {
|
||||
const [charDesc, charCodes] = digraphs[digraphKey];
|
||||
quickPicks.push({
|
||||
label: digraphKey,
|
||||
description: `${charDesc} (user)`,
|
||||
|
@ -40,7 +40,7 @@ export class FileCommand extends node.CommandBase {
|
||||
|
||||
// Need to do this before the split since it loses the activeTextEditor
|
||||
const editorFileUri = vscode.window.activeTextEditor!.document.uri;
|
||||
let editorFilePath = editorFileUri.fsPath;
|
||||
const editorFilePath = editorFileUri.fsPath;
|
||||
|
||||
// Do the split if requested
|
||||
let split = false;
|
||||
@ -53,7 +53,7 @@ export class FileCommand extends node.CommandBase {
|
||||
split = true;
|
||||
}
|
||||
|
||||
let hidePreviousEditor = async function () {
|
||||
const hidePreviousEditor = async () => {
|
||||
if (split === true) {
|
||||
await vscode.commands.executeCommand('workbench.action.previousEditor');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
@ -43,7 +43,7 @@ export class PutExCommand extends node.CommandBase {
|
||||
|
||||
vimState.recordedState.registerName = registerName;
|
||||
|
||||
let options: IPutCommandOptions = {
|
||||
const options: IPutCommandOptions = {
|
||||
forceLinewise: true,
|
||||
forceCursorLastLine: true,
|
||||
pasteBeforeCursor: this.arguments.bang,
|
||||
|
@ -74,7 +74,7 @@ export class RegisterCommand extends node.CommandBase {
|
||||
.sort((reg1: string, reg2: string) => this.regSortOrder(reg1) - this.regSortOrder(reg2));
|
||||
const registerKeyAndContent = new Array<vscode.QuickPickItem>();
|
||||
|
||||
for (let registerKey of currentRegisterKeys) {
|
||||
for (const registerKey of currentRegisterKeys) {
|
||||
registerKeyAndContent.push({
|
||||
label: registerKey,
|
||||
description: await this.getRegisterDisplayValue(vimState, registerKey),
|
||||
@ -83,7 +83,7 @@ export class RegisterCommand extends node.CommandBase {
|
||||
|
||||
vscode.window.showQuickPick(registerKeyAndContent).then(async (val) => {
|
||||
if (val) {
|
||||
let result = val.description;
|
||||
const result = val.description;
|
||||
vscode.window.showInformationMessage(`${val.label} ${result}`);
|
||||
}
|
||||
});
|
||||
|
@ -92,12 +92,12 @@ export class SetOptionsCommand extends node.CommandBase {
|
||||
if (typeof this._arguments.value! === 'number') {
|
||||
configuration[optionName] -= this._arguments.value;
|
||||
} else {
|
||||
let initialValue = configuration[optionName];
|
||||
const initialValue = configuration[optionName];
|
||||
configuration[optionName] = initialValue.split(this._arguments.value! as string).join('');
|
||||
}
|
||||
break;
|
||||
case SetOptionOperator.Info:
|
||||
let value = configuration[optionName];
|
||||
const value = configuration[optionName];
|
||||
if (value === undefined) {
|
||||
throw VimError.fromCode(ErrorCode.UnknownOption);
|
||||
} else {
|
||||
|
@ -50,9 +50,9 @@ export class SortCommand extends node.CommandBase {
|
||||
originalLines = [...new Set(originalLines)];
|
||||
}
|
||||
|
||||
let lastLineLength = originalLines[originalLines.length - 1].length;
|
||||
const lastLineLength = originalLines[originalLines.length - 1].length;
|
||||
|
||||
let sortedLines = this._arguments.ignoreCase
|
||||
const sortedLines = this._arguments.ignoreCase
|
||||
? originalLines.sort((a: string, b: string) => a.localeCompare(b))
|
||||
: originalLines.sort();
|
||||
|
||||
@ -60,7 +60,7 @@ export class SortCommand extends node.CommandBase {
|
||||
sortedLines.reverse();
|
||||
}
|
||||
|
||||
let sortedContent = sortedLines.join('\n');
|
||||
const sortedContent = sortedLines.join('\n');
|
||||
|
||||
await TextEditor.replace(
|
||||
vimState.editor,
|
||||
|
@ -292,7 +292,7 @@ export class SubstituteCommand extends node.CommandBase {
|
||||
|
||||
// TODO: Global Setting.
|
||||
// TODO: There are differencies between Vim Regex and JS Regex.
|
||||
let regex = this.getRegex(this._arguments, vimState);
|
||||
const regex = this.getRegex(this._arguments, vimState);
|
||||
let foundPattern = false;
|
||||
for (
|
||||
let currentLine = startLine;
|
||||
|
@ -76,7 +76,7 @@ export class WriteCommand extends node.CommandBase {
|
||||
await this.background(
|
||||
vimState.document.save().then(
|
||||
() => {
|
||||
let text =
|
||||
const text =
|
||||
'"' +
|
||||
path.basename(vimState.document.fileName) +
|
||||
'" ' +
|
||||
|
@ -35,7 +35,7 @@ export class WriteQuitCommand extends node.CommandBase {
|
||||
|
||||
// Writing command. Taken as a basis from the "write.ts" file.
|
||||
async execute(vimState: VimState): Promise<void> {
|
||||
let writeArgs: write.IWriteCommandArguments = {
|
||||
const writeArgs: write.IWriteCommandArguments = {
|
||||
opt: this.arguments.opt,
|
||||
optValue: this.arguments.optValue,
|
||||
bang: this.arguments.bang,
|
||||
@ -43,15 +43,15 @@ export class WriteQuitCommand extends node.CommandBase {
|
||||
range: this.arguments.range,
|
||||
};
|
||||
|
||||
let writeCmd = new write.WriteCommand(writeArgs);
|
||||
const writeCmd = new write.WriteCommand(writeArgs);
|
||||
await writeCmd.execute(vimState);
|
||||
let quitArgs: quit.IQuitCommandArguments = {
|
||||
const quitArgs: quit.IQuitCommandArguments = {
|
||||
// wq! fails when no file name is provided
|
||||
bang: false,
|
||||
range: this.arguments.range,
|
||||
};
|
||||
|
||||
let quitCmd = new quit.QuitCommand(quitArgs);
|
||||
const quitCmd = new quit.QuitCommand(quitArgs);
|
||||
await quitCmd.execute(vimState);
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ export class WriteQuitAllCommand extends node.CommandBase {
|
||||
|
||||
// Writing command. Taken as a basis from the "write.ts" file.
|
||||
async execute(vimState: VimState): Promise<void> {
|
||||
let writeArgs: wall.IWallCommandArguments = {
|
||||
const writeArgs: wall.IWallCommandArguments = {
|
||||
bang: this.arguments.bang,
|
||||
};
|
||||
|
||||
let quitArgs: quit.IQuitCommandArguments = {
|
||||
const quitArgs: quit.IQuitCommandArguments = {
|
||||
// wq! fails when no file name is provided
|
||||
bang: false,
|
||||
};
|
||||
|
@ -2,14 +2,12 @@ import { Scanner } from './scanner';
|
||||
import { Token, TokenType } from './token';
|
||||
|
||||
// Describes a function that can lex part of a Vim command line.
|
||||
interface ILexFunction {
|
||||
(state: Scanner, tokens: Token[]): ILexFunction | null;
|
||||
}
|
||||
type ILexFunction = (state: Scanner, tokens: Token[]) => ILexFunction | null;
|
||||
|
||||
export function lex(input: string): Token[] {
|
||||
// We use a character scanner as state for the lexer.
|
||||
const state = new Scanner(input);
|
||||
let tokens: Token[] = [];
|
||||
const tokens: Token[] = [];
|
||||
let f: ILexFunction | null = LexerFunctions.lexRange;
|
||||
while (f) {
|
||||
// Each lexing function returns the next lexing function or null.
|
||||
@ -134,7 +132,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 (state: Scanner, tokens: Token[]): ILexFunction | null => {
|
||||
// The first digit has already been lexed.
|
||||
while (true) {
|
||||
if (state.isAtEof) {
|
||||
|
@ -135,7 +135,7 @@ export class LineRange {
|
||||
|
||||
// now handle subsequent tokens, offsetting the current candidate line number
|
||||
for (let tokenIndex = 1; tokenIndex < toks.length; ++tokenIndex) {
|
||||
let currentToken = toks[tokenIndex];
|
||||
const currentToken = toks[tokenIndex];
|
||||
|
||||
switch (currentOperation) {
|
||||
case TokenType.Plus:
|
||||
|
@ -7,14 +7,12 @@ import { getParser } from './subparser';
|
||||
|
||||
const logger = Logger.get('Parser');
|
||||
|
||||
interface IParseFunction {
|
||||
(state: ParserState, command: CommandLine): IParseFunction | undefined;
|
||||
}
|
||||
type IParseFunction = (state: ParserState, command: CommandLine) => IParseFunction | undefined;
|
||||
|
||||
export function parse(input: string): CommandLine {
|
||||
const cmd = new CommandLine();
|
||||
let f: IParseFunction | undefined = parseLineRange;
|
||||
let state: ParserState = new ParserState(input);
|
||||
const state: ParserState = new ParserState(input);
|
||||
while (f) {
|
||||
f = f(state, cmd);
|
||||
}
|
||||
@ -23,7 +21,7 @@ export function parse(input: string): CommandLine {
|
||||
|
||||
function parseLineRange(state: ParserState, commandLine: CommandLine): IParseFunction | undefined {
|
||||
while (true) {
|
||||
let tok = state.next();
|
||||
const tok = state.next();
|
||||
switch (tok.type) {
|
||||
case TokenType.Eof:
|
||||
return undefined;
|
||||
@ -93,7 +91,7 @@ class ParserState {
|
||||
this.pos = this.tokens.length;
|
||||
return new Token(TokenType.Eof, '__EOF__');
|
||||
}
|
||||
let tok = this.tokens[this.pos];
|
||||
const tok = this.tokens[this.pos];
|
||||
this.pos++;
|
||||
return tok;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export class Scanner {
|
||||
this.pos = this.input.length;
|
||||
return Scanner.EOF;
|
||||
}
|
||||
let c = this.input[this.pos];
|
||||
const c = this.input[this.pos];
|
||||
this.pos++;
|
||||
return c;
|
||||
}
|
||||
@ -49,7 +49,7 @@ export class Scanner {
|
||||
}
|
||||
|
||||
let result = '';
|
||||
let c: string | undefined = undefined;
|
||||
let c: string | undefined;
|
||||
|
||||
while (!this.isAtEof) {
|
||||
c = this.next();
|
||||
@ -81,7 +81,7 @@ export class Scanner {
|
||||
|
||||
// Returns the span of text between the current start and the current position.
|
||||
emit(): string {
|
||||
let s = this.input.substring(this.start, this.pos);
|
||||
const s = this.input.substring(this.start, this.pos);
|
||||
this.ignore();
|
||||
return s;
|
||||
}
|
||||
@ -120,7 +120,7 @@ export class Scanner {
|
||||
return;
|
||||
}
|
||||
while (!this.isAtEof) {
|
||||
let c = this.next();
|
||||
const c = this.next();
|
||||
if (!chars.includes(c)) {
|
||||
break;
|
||||
}
|
||||
@ -158,7 +158,7 @@ export class Scanner {
|
||||
}
|
||||
|
||||
expectOneOf(values: string[]): void {
|
||||
let match = values.filter((s) => this.input.substr(this.pos).startsWith(s));
|
||||
const 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.');
|
||||
|
@ -6,16 +6,16 @@ export function parseEditFileCommandArgs(args: string): node.FileCommand {
|
||||
return new node.FileCommand({ name: '', createFileIfNotExists: true });
|
||||
}
|
||||
|
||||
let scanner = new Scanner(args);
|
||||
const scanner = new Scanner(args);
|
||||
const bang = scanner.next() === '!';
|
||||
if (scanner.isAtEof) {
|
||||
return new node.FileCommand({ name: '', bang: bang, createFileIfNotExists: true });
|
||||
return new node.FileCommand({ name: '', bang, createFileIfNotExists: true });
|
||||
}
|
||||
|
||||
let name = scanner.remaining();
|
||||
const name = scanner.remaining();
|
||||
return new node.FileCommand({
|
||||
name: name.trim(),
|
||||
bang: bang,
|
||||
bang,
|
||||
createFileIfNotExists: true,
|
||||
});
|
||||
}
|
||||
@ -31,12 +31,12 @@ export function parseEditFileInNewVerticalWindowCommandArgs(args: string): node.
|
||||
let name = '';
|
||||
|
||||
if (args) {
|
||||
let scanner = new Scanner(args);
|
||||
const scanner = new Scanner(args);
|
||||
name = scanner.nextWord();
|
||||
}
|
||||
|
||||
return new node.FileCommand({
|
||||
name: name,
|
||||
name,
|
||||
position: node.FilePosition.NewWindowVerticalSplit,
|
||||
});
|
||||
}
|
||||
@ -45,12 +45,12 @@ export function parseEditFileInNewHorizontalWindowCommandArgs(args: string): nod
|
||||
let name = '';
|
||||
|
||||
if (args) {
|
||||
let scanner = new Scanner(args);
|
||||
const scanner = new Scanner(args);
|
||||
name = scanner.nextWord();
|
||||
}
|
||||
|
||||
return new node.FileCommand({
|
||||
name: name,
|
||||
name,
|
||||
position: node.FilePosition.NewWindowHorizontalSplit,
|
||||
});
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export function parseQuitCommandArgs(args: string): node.QuitCommand {
|
||||
}
|
||||
|
||||
export function parseQuitAllCommandArgs(args: string): node.QuitCommand {
|
||||
let command = parseQuitCommandArgs(args);
|
||||
const command = parseQuitCommandArgs(args);
|
||||
command.arguments.quitAll = true;
|
||||
return command;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export function parseReadCommandArgs(args: string): ReadCommand {
|
||||
const scanner = new Scanner(args);
|
||||
|
||||
scanner.skipWhiteSpace();
|
||||
let c = scanner.next();
|
||||
const c = scanner.next();
|
||||
// read command has 2 forms - 'read <file-path>' and 'read! <shell-command>'
|
||||
if (c === '!') {
|
||||
scanner.ignore();
|
||||
|
@ -8,8 +8,8 @@ export function parseRegisterCommandArgs(args: string): RegisterCommand {
|
||||
});
|
||||
}
|
||||
|
||||
let scanner = new Scanner(args);
|
||||
let regs: string[] = [];
|
||||
const scanner = new Scanner(args);
|
||||
const regs: string[] = [];
|
||||
let reg = scanner.nextWord();
|
||||
while (reg !== Scanner.EOF) {
|
||||
regs.push(reg);
|
||||
|
@ -2,14 +2,14 @@ import * as node from '../commands/setoptions';
|
||||
import { Scanner } from '../scanner';
|
||||
|
||||
export function parseOption(args?: string): node.IOptionArgs {
|
||||
let scanner = new Scanner(args ?? '');
|
||||
const scanner = new Scanner(args ?? '');
|
||||
scanner.skipWhiteSpace();
|
||||
|
||||
if (scanner.isAtEof) {
|
||||
return {};
|
||||
}
|
||||
|
||||
let optionName = scanner.nextWord('?!&=:^+-'.split(''));
|
||||
const optionName = scanner.nextWord('?!&=:^+-'.split(''));
|
||||
|
||||
if (optionName.startsWith('no')) {
|
||||
return {
|
||||
@ -34,8 +34,8 @@ export function parseOption(args?: string): node.IOptionArgs {
|
||||
};
|
||||
}
|
||||
|
||||
let operator = scanner.next();
|
||||
let optionArgs: node.IOptionArgs = {
|
||||
const operator = scanner.next();
|
||||
const optionArgs: node.IOptionArgs = {
|
||||
name: optionName,
|
||||
value: scanner.nextWord([]),
|
||||
};
|
||||
|
@ -6,12 +6,12 @@ export function parseSortCommandArgs(args: string): node.SortCommand {
|
||||
return new node.SortCommand({ reverse: false, ignoreCase: false, unique: false });
|
||||
}
|
||||
|
||||
let scannedArgs: node.ISortCommandArguments = {
|
||||
const scannedArgs: node.ISortCommandArguments = {
|
||||
reverse: false,
|
||||
ignoreCase: false,
|
||||
unique: false,
|
||||
};
|
||||
let scanner = new Scanner(args);
|
||||
const scanner = new Scanner(args);
|
||||
const c = scanner.next();
|
||||
scannedArgs.reverse = c === '!';
|
||||
|
||||
|
@ -58,7 +58,7 @@ function parseSubstituteFlags(scanner: Scanner): number {
|
||||
break;
|
||||
}
|
||||
|
||||
let c = scanner.next();
|
||||
const c = scanner.next();
|
||||
switch (c) {
|
||||
case '&':
|
||||
if (index === 0) {
|
||||
@ -119,7 +119,7 @@ function parseCount(scanner: Scanner): number {
|
||||
countStr += scanner.next();
|
||||
}
|
||||
|
||||
let count = Number.parseInt(countStr, 10);
|
||||
const count = Number.parseInt(countStr, 10);
|
||||
|
||||
// TODO: If count is not valid number, raise error
|
||||
return Number.isInteger(count) ? count : -1;
|
||||
@ -147,7 +147,7 @@ export function parseSubstituteCommandArgs(args: string): node.SubstituteCommand
|
||||
}
|
||||
let scanner: Scanner;
|
||||
|
||||
let delimiter = args[0];
|
||||
const delimiter = args[0];
|
||||
|
||||
if (isValidDelimiter(delimiter)) {
|
||||
if (args.length === 1) {
|
||||
@ -188,8 +188,8 @@ export function parseSubstituteCommandArgs(args: string): node.SubstituteCommand
|
||||
return new node.SubstituteCommand({
|
||||
pattern: searchPattern,
|
||||
replace: replaceString,
|
||||
flags: flags,
|
||||
count: count,
|
||||
flags,
|
||||
count,
|
||||
});
|
||||
} catch (e) {
|
||||
throw error.VimError.fromCode(error.ErrorCode.PatternNotFound);
|
||||
|
@ -122,7 +122,7 @@ export function parseTabNewCommandArgs(args: string): node.TabCommand {
|
||||
let name = '';
|
||||
|
||||
if (args) {
|
||||
let scanner = new Scanner(args);
|
||||
const scanner = new Scanner(args);
|
||||
name = scanner.nextWord();
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ export function parseWriteCommandArgs(args: string): WriteCommand {
|
||||
scanner.backup();
|
||||
continue;
|
||||
}
|
||||
let value = scanner.emit();
|
||||
const value = scanner.emit();
|
||||
if (!value) {
|
||||
throw new Error('Expected value for option.');
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export function parseWriteQuitCommandArgs(args: string): WriteQuitCommand {
|
||||
scanner.backup();
|
||||
continue;
|
||||
}
|
||||
let value = scanner.emit();
|
||||
const value = scanner.emit();
|
||||
if (!value) {
|
||||
throw new Error('Expected value for option.');
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class TagMatcher {
|
||||
const stack: Tag[] = [];
|
||||
const matchedTags: MatchedTag[] = [];
|
||||
|
||||
for (let tag of tags) {
|
||||
for (const tag of tags) {
|
||||
// We have to push on the stack
|
||||
// if it is an open tag.
|
||||
if (tag.type === 'open') {
|
||||
|
@ -566,13 +566,13 @@ Position.prototype.isValid = function (this: Position, textEditor: vscode.TextEd
|
||||
try {
|
||||
// line
|
||||
// TODO: this `|| 1` seems dubious...
|
||||
let lineCount = TextEditor.getLineCount(textEditor) || 1;
|
||||
const lineCount = TextEditor.getLineCount(textEditor) || 1;
|
||||
if (this.line >= lineCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// char
|
||||
let charCount = TextEditor.getLineLength(this.line);
|
||||
const charCount = TextEditor.getLineLength(this.line);
|
||||
if (this.character > charCount + 1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class NumericString {
|
||||
// '000009' matches decimal.
|
||||
// '000007' matches octal.
|
||||
// '-0xf' matches hex rather than decimal '-0'
|
||||
private static matchings: { regex: RegExp; radix: number }[] = [
|
||||
private static matchings: Array<{ regex: RegExp; radix: number }> = [
|
||||
{ regex: /(-)?0[0-7]+/, radix: 8 },
|
||||
{ regex: /(-)?\d+/, radix: 10 },
|
||||
{ regex: /(-)?0x[\da-fA-F]+/, radix: 16 },
|
||||
|
@ -31,7 +31,7 @@ const linesWithoutIndentation = (
|
||||
document: vscode.TextDocument,
|
||||
lineToStartScanFrom: number,
|
||||
scanAboveFirst: boolean
|
||||
): { sortPriority: number; text: string }[] => {
|
||||
): Array<{ sortPriority: number; text: string }> => {
|
||||
const distanceFromStartLine = (line: number) => {
|
||||
let sortPriority = scanAboveFirst ? lineToStartScanFrom - line : line - lineToStartScanFrom;
|
||||
if (sortPriority < 0) {
|
||||
|
@ -99,12 +99,11 @@ class Configuration implements IConfiguration {
|
||||
};
|
||||
|
||||
public async load(): Promise<ValidatorResults> {
|
||||
let vimConfigs: any = Globals.isTesting
|
||||
const vimConfigs: any = Globals.isTesting
|
||||
? Globals.mockConfiguration
|
||||
: this.getConfiguration('vim');
|
||||
|
||||
/* tslint:disable:forin */
|
||||
// Disable forin rule here as we make accessors enumerable.`
|
||||
// tslint:disable-next-line: forin
|
||||
for (const option in this) {
|
||||
let val = vimConfigs[option];
|
||||
if (val !== null && val !== undefined) {
|
||||
@ -130,7 +129,7 @@ class Configuration implements IConfiguration {
|
||||
// read package.json for bound keys
|
||||
// enable/disable certain key combinations
|
||||
this.boundKeyCombinations = [];
|
||||
for (let keybinding of packagejson.contributes.keybindings) {
|
||||
for (const keybinding of packagejson.contributes.keybindings) {
|
||||
if (keybinding.when.includes('listFocus')) {
|
||||
continue;
|
||||
}
|
||||
@ -159,7 +158,7 @@ class Configuration implements IConfiguration {
|
||||
// By default, all key combinations are used
|
||||
let useKey = true;
|
||||
|
||||
let handleKey = this.handleKeys[boundKey.key];
|
||||
const handleKey = this.handleKeys[boundKey.key];
|
||||
if (handleKey !== undefined) {
|
||||
// enabled/disabled through `vim.handleKeys`
|
||||
useKey = handleKey;
|
||||
@ -441,10 +440,11 @@ class Configuration implements IConfiguration {
|
||||
visualModeKeyBindingsMap: Map<string, IKeyRemapping>;
|
||||
commandLineModeKeyBindingsMap: Map<string, IKeyRemapping>;
|
||||
|
||||
private static unproxify(obj: Object): Object {
|
||||
let result = {};
|
||||
private static unproxify(obj: object): object {
|
||||
const result = {};
|
||||
// tslint:disable-next-line: forin
|
||||
for (const key in obj) {
|
||||
let val = obj[key] as any;
|
||||
const val = obj[key] as any;
|
||||
if (val !== null && val !== undefined) {
|
||||
result[key] = val;
|
||||
}
|
||||
@ -459,9 +459,9 @@ function overlapSetting(args: {
|
||||
defaultValue: OptionValue;
|
||||
map?: Map<string | number | boolean, string | number | boolean>;
|
||||
}) {
|
||||
return function (target: any, propertyKey: string) {
|
||||
return (target: any, propertyKey: string) => {
|
||||
Object.defineProperty(target, propertyKey, {
|
||||
get: function () {
|
||||
get() {
|
||||
// retrieve value from vim configuration
|
||||
// if the value is not defined or empty
|
||||
// look at the equivalent `editor` setting
|
||||
@ -478,7 +478,7 @@ function overlapSetting(args: {
|
||||
|
||||
return val;
|
||||
},
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
// synchronize the vim setting with the `editor` equivalent
|
||||
this['_' + propertyKey] = value;
|
||||
|
||||
@ -487,7 +487,7 @@ function overlapSetting(args: {
|
||||
}
|
||||
|
||||
if (args.map) {
|
||||
for (let [vscodeSetting, vimSetting] of args.map.entries()) {
|
||||
for (const [vscodeSetting, vimSetting] of args.map.entries()) {
|
||||
if (value === vimSetting) {
|
||||
value = vscodeSetting;
|
||||
break;
|
||||
|
@ -16,7 +16,7 @@ class ConfigurationValidator {
|
||||
const results = new ValidatorResults();
|
||||
|
||||
for (const validator of this._validators) {
|
||||
let validatorResults = await validator.validate(config);
|
||||
const validatorResults = await validator.validate(config);
|
||||
if (validatorResults.hasError) {
|
||||
// errors found in configuration, disable feature
|
||||
validator.disable(config);
|
||||
|
@ -52,6 +52,10 @@ class DecorationImpl {
|
||||
return this._searchHighlight;
|
||||
}
|
||||
|
||||
public get easyMotionIncSearch() {
|
||||
return this._easyMotionIncSearch;
|
||||
}
|
||||
|
||||
public set easyMotionIncSearch(value: vscode.TextEditorDecorationType) {
|
||||
if (this._easyMotionIncSearch) {
|
||||
this._easyMotionIncSearch.dispose();
|
||||
@ -59,6 +63,10 @@ class DecorationImpl {
|
||||
this._easyMotionIncSearch = value;
|
||||
}
|
||||
|
||||
public get easyMotionDimIncSearch() {
|
||||
return this._easyMotionDimIncSearch;
|
||||
}
|
||||
|
||||
public set easyMotionDimIncSearch(value: vscode.TextEditorDecorationType) {
|
||||
if (this._easyMotionDimIncSearch) {
|
||||
this._easyMotionDimIncSearch.dispose();
|
||||
@ -66,14 +74,6 @@ class DecorationImpl {
|
||||
this._easyMotionDimIncSearch = value;
|
||||
}
|
||||
|
||||
public get easyMotionIncSearch() {
|
||||
return this._easyMotionIncSearch;
|
||||
}
|
||||
|
||||
public get easyMotionDimIncSearch() {
|
||||
return this._easyMotionDimIncSearch;
|
||||
}
|
||||
|
||||
public getOrCreateMarkDecoration(name: string): vscode.TextEditorDecorationType {
|
||||
const decorationType = this.getMarkDecoration(name);
|
||||
|
||||
|
@ -16,7 +16,7 @@ export interface IKeyRemapping {
|
||||
after?: string[];
|
||||
// 'recursive' is calculated when validating, according to the config that stored the remapping
|
||||
recursive?: boolean;
|
||||
commands?: ({ command: string; args: any[] } | string)[];
|
||||
commands?: Array<{ command: string; args: any[] } | string>;
|
||||
source?: 'vscode' | 'vimrc';
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ export class Remappers implements IRemapper {
|
||||
public async sendKey(keys: string[], modeHandler: ModeHandler): Promise<boolean> {
|
||||
let handled = false;
|
||||
|
||||
for (let remapper of this.remappers) {
|
||||
for (const remapper of this.remappers) {
|
||||
handled = handled || (await remapper.sendKey(keys, modeHandler));
|
||||
}
|
||||
return handled;
|
||||
@ -303,7 +303,7 @@ export class Remapper implements IRemapper {
|
||||
// remapping from waiting for the timeout again by making a clone of
|
||||
// remapping and change 'after' to send the '<TimeoutFinished>' key at
|
||||
// the end.
|
||||
let newRemapping = { ...remapping };
|
||||
const newRemapping = { ...remapping };
|
||||
newRemapping.after = remapping.after?.slice(0);
|
||||
newRemapping.after?.push(SpecialKeys.TimeoutFinished);
|
||||
remapping = newRemapping;
|
||||
@ -584,7 +584,7 @@ export class Remapper implements IRemapper {
|
||||
const keysAsString = keys.join('');
|
||||
const re = /^<([^>]+)>/;
|
||||
if (keysAsString !== '') {
|
||||
for (let remap of remappings.keys()) {
|
||||
for (const remap of remappings.keys()) {
|
||||
if (remap.startsWith(keysAsString) && (remap !== keysAsString || countRemapAsPotential)) {
|
||||
// Don't confuse a key combination starting with '<' that is not a special key like '<C-a>'
|
||||
// with a remap that starts with a special key.
|
||||
|
@ -45,7 +45,7 @@ export class NeovimValidator implements IConfigurationValidator {
|
||||
// If Neovim config path doesn't exist, default to empty config path.
|
||||
if (config.neovimUseConfigFile && config.neovimConfigPath !== '') {
|
||||
if (!existsSync(config.neovimConfigPath)) {
|
||||
let warningMessage = `No config file found in neovimConfigPath. Neovim will search its default config path.`;
|
||||
const warningMessage = `No config file found in neovimConfigPath. Neovim will search its default config path.`;
|
||||
config.neovimConfigPath = '';
|
||||
result.append({
|
||||
level: 'warning',
|
||||
|
@ -22,7 +22,7 @@ export class RemappingValidator implements IConfigurationValidator {
|
||||
'commandLineModeKeyBindingsNonRecursive',
|
||||
];
|
||||
for (const modeKeyBindingsKey of modeKeyBindingsKeys) {
|
||||
let keybindings = config[modeKeyBindingsKey];
|
||||
const keybindings = config[modeKeyBindingsKey];
|
||||
const isRecursive = modeKeyBindingsKey.indexOf('NonRecursive') === -1;
|
||||
|
||||
const modeMapName = modeKeyBindingsKey.replace('NonRecursive', '');
|
||||
@ -31,13 +31,13 @@ export class RemappingValidator implements IConfigurationValidator {
|
||||
modeKeyBindingsMap = new Map<string, IKeyRemapping>();
|
||||
}
|
||||
for (let i = keybindings.length - 1; i >= 0; i--) {
|
||||
let remapping = keybindings[i] as IKeyRemapping;
|
||||
const remapping = keybindings[i] as IKeyRemapping;
|
||||
|
||||
// set 'recursive' of the remapping according to where it was stored
|
||||
remapping.recursive = isRecursive;
|
||||
|
||||
// validate
|
||||
let remappingError = await this.isRemappingValid(remapping);
|
||||
const remappingError = await this.isRemappingValid(remapping);
|
||||
result.concat(remappingError);
|
||||
if (remappingError.hasError) {
|
||||
// errors with remapping, skip
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { IConfiguration } from '../iconfiguration';
|
||||
import { IConfigurationValidator, ValidatorResults } from '../iconfigurationValidator';
|
||||
import { vimrc } from '../vimrc';
|
||||
import { configurationValidator } from '../configurationValidator';
|
||||
|
||||
export class VimrcValidator implements IConfigurationValidator {
|
||||
|
@ -224,7 +224,7 @@ class VimrcKeyRemappingBuilderImpl {
|
||||
}
|
||||
|
||||
private static buildKeyList(keyString: string): string[] {
|
||||
let keyList: string[] = [];
|
||||
const keyList: string[] = [];
|
||||
let matches: RegExpMatchArray | null = null;
|
||||
do {
|
||||
matches = VimrcKeyRemappingBuilderImpl.KEY_LIST_REG_EX.exec(keyString);
|
||||
|
@ -359,7 +359,7 @@ export class HistoryTracker {
|
||||
*/
|
||||
private updateAndReturnMarks(): IMark[] {
|
||||
const previousMarks = this.getAllCurrentDocumentMarks();
|
||||
let newMarks: IMark[] = [];
|
||||
const newMarks: IMark[] = [];
|
||||
|
||||
// clone old marks into new marks
|
||||
for (const mark of previousMarks) {
|
||||
@ -479,7 +479,7 @@ export class HistoryTracker {
|
||||
const newMark: IMark = {
|
||||
position,
|
||||
name: markName,
|
||||
isUppercaseMark: isUppercaseMark,
|
||||
isUppercaseMark,
|
||||
editor: isUppercaseMark ? vscode.window.activeTextEditor : undefined,
|
||||
};
|
||||
this.putMarkInList(newMark);
|
||||
@ -709,7 +709,7 @@ export class HistoryTracker {
|
||||
|
||||
let done: boolean = false;
|
||||
let stepsToUndo: number = 0;
|
||||
let changesToUndo: DocumentChange[] = [];
|
||||
const changesToUndo: DocumentChange[] = [];
|
||||
|
||||
const changes = currentHistoryStep.changes;
|
||||
|
||||
|
@ -147,7 +147,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
// might close or change to other document
|
||||
return;
|
||||
}
|
||||
let selection = e.selections[0];
|
||||
const selection = e.selections[0];
|
||||
ModeHandler.logger.debug(
|
||||
`Selections: Handling Selection Change! Selection: ${selection.anchor.toString()}, ${
|
||||
selection.active
|
||||
@ -166,7 +166,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
(e.selections.length !== this.vimState.cursors.length || this.vimState.isMultiCursor) &&
|
||||
this.vimState.currentMode !== Mode.VisualBlock
|
||||
) {
|
||||
let allowedModes = [Mode.Normal];
|
||||
const allowedModes = [Mode.Normal];
|
||||
if (!isSnippetSelectionChange()) {
|
||||
allowedModes.push(...[Mode.Insert, Mode.Replace]);
|
||||
}
|
||||
@ -201,7 +201,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
if (e.kind === vscode.TextEditorSelectionChangeKind.Command) {
|
||||
// This 'Command' kind is triggered when using a command like 'editor.action.smartSelect.grow'
|
||||
// but it is also triggered when we set the 'editor.selections' on 'updateView'.
|
||||
let allowedModes = [Mode.Normal, Mode.Visual];
|
||||
const allowedModes = [Mode.Normal, Mode.Visual];
|
||||
if (!isSnippetSelectionChange()) {
|
||||
// if we just inserted a snippet then don't allow insert modes to go to visual mode
|
||||
allowedModes.push(...[Mode.Insert, Mode.Replace]);
|
||||
@ -563,7 +563,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
this.vimState.keyHistory.push(key);
|
||||
|
||||
let recordedState = this.vimState.recordedState;
|
||||
const recordedState = this.vimState.recordedState;
|
||||
recordedState.actionKeys.push(key);
|
||||
|
||||
const action = getRelevantAction(recordedState.actionKeys, this.vimState);
|
||||
@ -599,7 +599,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
if (recordedState.actionsRun.length === 0) {
|
||||
recordedState.actionsRun.push(action);
|
||||
} else {
|
||||
let lastAction = recordedState.actionsRun[recordedState.actionsRun.length - 1];
|
||||
const lastAction = recordedState.actionsRun[recordedState.actionsRun.length - 1];
|
||||
|
||||
if (lastAction instanceof DocumentContentChangeAction) {
|
||||
lastAction.keysPressed.push(key);
|
||||
@ -623,7 +623,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
) {
|
||||
// This means we are already in Insert Mode but there is still not DocumentContentChangeAction in stack
|
||||
this.vimState.historyTracker.currentContentChanges = [];
|
||||
let newContentChange = new DocumentContentChangeAction();
|
||||
const newContentChange = new DocumentContentChangeAction();
|
||||
newContentChange.keysPressed.push(key);
|
||||
recordedState.actionsRun.push(newContentChange);
|
||||
actionToRecord = newContentChange;
|
||||
@ -907,8 +907,8 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
private async executeMovement(movement: BaseMovement): Promise<RecordedState> {
|
||||
this.vimState.lastMovementFailed = false;
|
||||
let recordedState = this.vimState.recordedState;
|
||||
let cursorsToRemove: number[] = [];
|
||||
const recordedState = this.vimState.recordedState;
|
||||
const cursorsToRemove: number[] = [];
|
||||
|
||||
for (let i = 0; i < this.vimState.cursors.length; i++) {
|
||||
/**
|
||||
@ -928,7 +928,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
movement.multicursorIndex = i;
|
||||
|
||||
this.vimState.cursorStartPosition = this.vimState.cursors[i].start;
|
||||
let cursorPosition = this.vimState.cursors[i].stop;
|
||||
const cursorPosition = this.vimState.cursors[i].stop;
|
||||
this.vimState.cursorStopPosition = cursorPosition;
|
||||
|
||||
const result = await movement.execActionWithCount(
|
||||
@ -988,7 +988,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
// Keep the cursor within bounds
|
||||
if (this.vimState.currentMode !== Mode.Normal || recordedState.operator) {
|
||||
let stop = this.vimState.cursorStopPosition;
|
||||
const stop = this.vimState.cursorStopPosition;
|
||||
|
||||
// Vim does this weird thing where it allows you to select and delete
|
||||
// the newline character, which it places 1 past the last character
|
||||
@ -1048,7 +1048,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
let resultingRange = new Range(
|
||||
const resultingRange = new Range(
|
||||
this.vimState.cursorStartPosition,
|
||||
this.vimState.cursorStopPosition
|
||||
);
|
||||
@ -1105,8 +1105,8 @@ export class ModeHandler implements vscode.Disposable {
|
||||
this.vimState.recordedState = recordedState;
|
||||
this.vimState.isRunningDotCommand = true;
|
||||
|
||||
for (let action of recordedMacro.actionsRun) {
|
||||
let originalLocation = Jump.fromStateNow(this.vimState);
|
||||
for (const action of recordedMacro.actionsRun) {
|
||||
const originalLocation = Jump.fromStateNow(this.vimState);
|
||||
|
||||
this.vimState.cursorsInitialState = this.vimState.cursors;
|
||||
|
||||
@ -1221,7 +1221,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
* there would be a selectionChangeEvent when there wouldn't be any.
|
||||
*/
|
||||
const getSelectionsCombined = (sel: vscode.Selection[]) => {
|
||||
let combinedSelections: vscode.Selection[] = [];
|
||||
const combinedSelections: vscode.Selection[] = [];
|
||||
sel.forEach((s, i) => {
|
||||
if (i > 0) {
|
||||
const previousSelection = combinedSelections[combinedSelections.length - 1];
|
||||
@ -1401,7 +1401,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
this.vimState.editor.options.cursorStyle = cursorStyle;
|
||||
|
||||
// cursor block
|
||||
let cursorRange: vscode.Range[] = [];
|
||||
const cursorRange: vscode.Range[] = [];
|
||||
if (
|
||||
getCursorType(this.vimState, this.currentMode) === VSCodeVimCursorType.TextDecoration &&
|
||||
this.currentMode !== Mode.Insert
|
||||
@ -1428,9 +1428,9 @@ export class ModeHandler implements vscode.Disposable {
|
||||
// Insert Mode virtual characters: used to temporarily show the remapping pressed keys on
|
||||
// insert mode, to show the `"` character after pressing `<C-r>`, and to show `?` and the
|
||||
// first character when inserting digraphs with `<C-k>`.
|
||||
let iModeVirtualCharDecorationOptions: vscode.DecorationOptions[] = [];
|
||||
const iModeVirtualCharDecorationOptions: vscode.DecorationOptions[] = [];
|
||||
if (this.vimState.currentMode === Mode.Insert || this.vimState.currentMode === Mode.Replace) {
|
||||
let virtualKey: string | undefined = undefined;
|
||||
let virtualKey: string | undefined;
|
||||
if (this.vimState.recordedState.bufferedKeys.length > 0) {
|
||||
virtualKey = this.vimState.recordedState.bufferedKeys[
|
||||
this.vimState.recordedState.bufferedKeys.length - 1
|
||||
@ -1478,7 +1478,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
} else {
|
||||
iModeVirtualCharDecorationOptions.push({
|
||||
range: new vscode.Range(cursorStop, cursorStop.getRightThroughLineBreaks(true)),
|
||||
renderOptions: renderOptions,
|
||||
renderOptions,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1505,11 +1505,11 @@ export class ModeHandler implements vscode.Disposable {
|
||||
};
|
||||
opCursorDecorations.push({
|
||||
range: new vscode.Range(cursorStop, cursorStop.getRight()),
|
||||
renderOptions: renderOptions,
|
||||
renderOptions,
|
||||
});
|
||||
opCursorCharDecorations.push({
|
||||
range: new vscode.Range(cursorStop, cursorStop.getRight()),
|
||||
renderOptions: renderOptions,
|
||||
renderOptions,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ export class NeovimWrapper implements vscode.Disposable {
|
||||
if (!(await util.promisify(exists)(dir))) {
|
||||
dir = __dirname;
|
||||
}
|
||||
let neovimArgs: Array<string> = [];
|
||||
const neovimArgs: string[] = [];
|
||||
// '-u' flag is only added if user wants to use a custom path for
|
||||
// their config file OR they want no config file to be loaded at all.
|
||||
// '-u' flag is omitted altogether if user wants Neovim to look for a
|
||||
@ -187,7 +187,7 @@ export class NeovimWrapper implements vscode.Disposable {
|
||||
|
||||
NeovimWrapper.logger.debug(`${lines.length} lines in nvim. ${lineCount} in editor.`);
|
||||
|
||||
let [row, character] = ((await this.nvim.callFunction('getpos', ['.'])) as Array<number>).slice(
|
||||
const [row, character] = ((await this.nvim.callFunction('getpos', ['.'])) as number[]).slice(
|
||||
1,
|
||||
3
|
||||
);
|
||||
|
@ -29,7 +29,7 @@ export class HistoryBase {
|
||||
}
|
||||
|
||||
// remove duplicates
|
||||
let index: number = this._history.indexOf(value);
|
||||
const index: number = this._history.indexOf(value);
|
||||
if (index !== -1) {
|
||||
this._history.splice(index, 1);
|
||||
}
|
||||
@ -60,12 +60,12 @@ export class HistoryBase {
|
||||
}
|
||||
|
||||
public async load(): Promise<void> {
|
||||
let data = this._context.workspaceState.get<string>(this.historyKey) || '';
|
||||
const data = this._context.workspaceState.get<string>(this.historyKey) || '';
|
||||
if (data.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let parsedData = JSON.parse(data);
|
||||
const parsedData = JSON.parse(data);
|
||||
if (!Array.isArray(parsedData)) {
|
||||
throw Error('Unexpected format in history. Expected JSON.');
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export class VsCodeMessage implements ILogger {
|
||||
showMessage = console.log;
|
||||
break;
|
||||
default:
|
||||
throw 'Unsupported ' + info.level;
|
||||
throw Error(`Unsupported log level ${info.level}`);
|
||||
}
|
||||
|
||||
showMessage(`${this.prefix}: ${info.message}`, ...this.actionMessages);
|
||||
|
@ -34,7 +34,7 @@ export class HistoryBase {
|
||||
}
|
||||
|
||||
// remove duplicates
|
||||
let index: number = this._history.indexOf(value);
|
||||
const index: number = this._history.indexOf(value);
|
||||
if (index !== -1) {
|
||||
this._history.splice(index, 1);
|
||||
}
|
||||
@ -88,7 +88,7 @@ export class HistoryBase {
|
||||
}
|
||||
|
||||
try {
|
||||
let parsedData = JSON.parse(data);
|
||||
const parsedData = JSON.parse(data);
|
||||
if (!Array.isArray(parsedData)) {
|
||||
throw Error('Unexpected format in history file. Expected JSON.');
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class VsCodeMessage extends TransportStream {
|
||||
this.prefix = options.prefix;
|
||||
}
|
||||
|
||||
public async log(info: { level: string; message: string }, callback: Function) {
|
||||
public async log(info: { level: string; message: string }, callback: () => void) {
|
||||
if (configuration.debug.silent) {
|
||||
return;
|
||||
}
|
||||
@ -41,7 +41,7 @@ class VsCodeMessage extends TransportStream {
|
||||
showMessage = vscode.window.showInformationMessage;
|
||||
break;
|
||||
default:
|
||||
throw 'Unsupported ' + info.level;
|
||||
throw Error(`Unsupported log level ${info.level}`);
|
||||
}
|
||||
|
||||
const message = `${this.prefix}: ${info.message}`;
|
||||
@ -70,11 +70,11 @@ class NodeLogger implements ILogger {
|
||||
new ConsoleForElectron({
|
||||
level: configuration.debug.loggingLevelForConsole,
|
||||
silent: configuration.debug.silent,
|
||||
prefix: prefix,
|
||||
prefix,
|
||||
}),
|
||||
new VsCodeMessage({
|
||||
level: configuration.debug.loggingLevelForAlert,
|
||||
prefix: prefix,
|
||||
prefix,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
@ -134,7 +134,7 @@ export class Register {
|
||||
});
|
||||
}
|
||||
|
||||
let registerContent = Register.registers.get(register.toLowerCase())!;
|
||||
const registerContent = Register.registers.get(register.toLowerCase())!;
|
||||
|
||||
if (!Array.isArray(registerContent.text)) {
|
||||
registerContent.text = [];
|
||||
@ -194,7 +194,7 @@ export class Register {
|
||||
}
|
||||
}
|
||||
|
||||
let currentRegisterMode = vimState.effectiveRegisterMode;
|
||||
const currentRegisterMode = vimState.effectiveRegisterMode;
|
||||
if (
|
||||
appendToRegister.registerMode === RegisterMode.CharacterWise &&
|
||||
currentRegisterMode === RegisterMode.CharacterWise
|
||||
@ -239,7 +239,7 @@ export class Register {
|
||||
vimState: VimState
|
||||
): void {
|
||||
register = register.toLowerCase();
|
||||
let currentRegisterMode = vimState.effectiveRegisterMode;
|
||||
const currentRegisterMode = vimState.effectiveRegisterMode;
|
||||
let appendToRegister = Register.registers.get(register);
|
||||
if (appendToRegister === undefined) {
|
||||
appendToRegister = { registerMode: currentRegisterMode, text: '' };
|
||||
|
@ -109,7 +109,7 @@ class GlobalState {
|
||||
.map((searchState) => {
|
||||
return {
|
||||
label: searchState.searchString,
|
||||
searchState: searchState,
|
||||
searchState,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -29,7 +29,7 @@ export class ReplaceState {
|
||||
this.timesToRepeat = timesToRepeat;
|
||||
|
||||
const text = vimState.document.lineAt(startPosition).text.substring(startPosition.character);
|
||||
for (let [key, value] of text.split('').entries()) {
|
||||
for (const [key, value] of text.split('').entries()) {
|
||||
this.originalChars[key + startPosition.character] = value;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export class SearchState {
|
||||
public getMatchRanges(editor: vscode.TextEditor): vscode.Range[] {
|
||||
return this.recalculateSearchRanges(editor);
|
||||
}
|
||||
private matchRanges: Map<string, { version: number; ranges: Array<vscode.Range> }> = new Map();
|
||||
private matchRanges: Map<string, { version: number; ranges: vscode.Range[] }> = new Map();
|
||||
|
||||
/**
|
||||
* Whether the needle should be interpreted as a regular expression
|
||||
@ -113,7 +113,7 @@ export class SearchState {
|
||||
} else {
|
||||
this.offset = {
|
||||
type: 'line',
|
||||
num: num,
|
||||
num,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -196,7 +196,7 @@ export class SearchState {
|
||||
|
||||
let result: RegExpExecArray | null;
|
||||
let wrappedOver = false;
|
||||
let matchRanges = [] as vscode.Range[];
|
||||
const matchRanges = [] as vscode.Range[];
|
||||
while (true) {
|
||||
result = regex.exec(text);
|
||||
|
||||
@ -355,7 +355,7 @@ export class SearchState {
|
||||
return { start: pos, end: pos, match: false, index: -1 };
|
||||
}
|
||||
|
||||
for (let [index, matchRange] of matchRanges.entries()) {
|
||||
for (const [index, matchRange] of matchRanges.entries()) {
|
||||
if (matchRange.start.isBeforeOrEqual(pos) && matchRange.end.isAfter(pos)) {
|
||||
return {
|
||||
start: matchRange.start,
|
||||
|
@ -85,7 +85,7 @@ class StatusBarImpl implements vscode.Disposable {
|
||||
return;
|
||||
}
|
||||
|
||||
let text: string[] = [];
|
||||
const text: string[] = [];
|
||||
|
||||
if (configuration.showmodename) {
|
||||
text.push(statusBarText(vimState));
|
||||
@ -110,10 +110,10 @@ class StatusBarImpl implements vscode.Disposable {
|
||||
}
|
||||
|
||||
private updateColor(mode: Mode) {
|
||||
let foreground: string | undefined = undefined;
|
||||
let background: string | undefined = undefined;
|
||||
let foreground: string | undefined;
|
||||
let background: string | undefined;
|
||||
|
||||
let colorToSet = configuration.statusBarColors[Mode[mode].toLowerCase()];
|
||||
const colorToSet = configuration.statusBarColors[Mode[mode].toLowerCase()];
|
||||
|
||||
if (colorToSet !== undefined) {
|
||||
if (typeof colorToSet === 'string') {
|
||||
@ -184,12 +184,12 @@ export function statusBarText(vimState: VimState) {
|
||||
const leadingChar =
|
||||
globalState.searchState.searchDirection === SearchDirection.Forward ? '/' : '?';
|
||||
|
||||
let searchWithCursor = globalState.searchState.searchString.split('');
|
||||
const searchWithCursor = globalState.searchState.searchString.split('');
|
||||
searchWithCursor.splice(vimState.statusBarCursorCharacterPos, 0, cursorChar);
|
||||
|
||||
return `${leadingChar}${searchWithCursor.join('')}`;
|
||||
case Mode.CommandlineInProgress:
|
||||
let commandWithCursor = vimState.currentCommandlineText.split('');
|
||||
const commandWithCursor = vimState.currentCommandlineText.split('');
|
||||
commandWithCursor.splice(vimState.statusBarCursorCharacterPos, 0, cursorChar);
|
||||
|
||||
return `:${commandWithCursor.join('')}`;
|
||||
|
@ -30,7 +30,7 @@ class TaskQueue {
|
||||
|
||||
private async runTasks(queueName: string): Promise<void> {
|
||||
while (this._taskQueue[queueName].tasks.length > 0) {
|
||||
let task: IEnqueuedTask = this._taskQueue[queueName].tasks[0];
|
||||
const task: IEnqueuedTask = this._taskQueue[queueName].tasks[0];
|
||||
|
||||
try {
|
||||
task.isRunning = true;
|
||||
@ -83,10 +83,10 @@ class TaskQueue {
|
||||
queueName: string = 'default',
|
||||
isHighPriority: boolean = false
|
||||
): void {
|
||||
let task: IEnqueuedTask = {
|
||||
const task: IEnqueuedTask = {
|
||||
promise: action,
|
||||
queue: queueName,
|
||||
isHighPriority: isHighPriority,
|
||||
isHighPriority,
|
||||
isRunning: false,
|
||||
};
|
||||
|
||||
|
@ -22,8 +22,8 @@ export class TextEditor {
|
||||
static async insert(
|
||||
editor: vscode.TextEditor,
|
||||
text: string,
|
||||
at: Position | undefined = undefined,
|
||||
letVSCodeHandleKeystrokes: boolean | undefined = undefined
|
||||
at?: Position,
|
||||
letVSCodeHandleKeystrokes?: boolean
|
||||
): Promise<void> {
|
||||
// If we insert "blah(" with default:type, VSCode will insert the closing ).
|
||||
// We *probably* don't want that to happen if we're inserting a lot of text.
|
||||
@ -280,9 +280,9 @@ export class TextEditor {
|
||||
do {
|
||||
const word = text.substring(start.character, wordEnd.character + 1);
|
||||
yield {
|
||||
start: start,
|
||||
start,
|
||||
end: wordEnd,
|
||||
word: word,
|
||||
word,
|
||||
};
|
||||
|
||||
if (wordEnd.getRight().isLineEnd()) {
|
||||
|
@ -91,8 +91,8 @@ export class SelectWord extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -154,8 +154,8 @@ export class SelectABigWord extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection {
|
||||
return !range.failed;
|
||||
});
|
||||
|
||||
let smallestRange: Range | undefined = undefined;
|
||||
let smallestRange: Range | undefined;
|
||||
|
||||
for (const iMotion of ranges) {
|
||||
const currentSelectedRange = new Range(
|
||||
@ -212,7 +212,7 @@ export class SelectAnExpandingBlock extends ExpandingSelection {
|
||||
}
|
||||
|
||||
const range = new Range(iMotion.start, iMotion.stop);
|
||||
let contender: Range | undefined = undefined;
|
||||
let contender: Range | undefined;
|
||||
|
||||
if (
|
||||
range.start.isBefore(currentSelectedRange.start) &&
|
||||
@ -298,8 +298,8 @@ export class SelectInnerWord extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -339,8 +339,8 @@ export class SelectInnerBigWord extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -396,8 +396,8 @@ export class SelectSentence extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -439,8 +439,8 @@ export class SelectInnerSentence extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -476,8 +476,8 @@ export class SelectParagraph extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -521,8 +521,8 @@ export class SelectInnerParagraph extends TextObjectMovement {
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
stop: stop,
|
||||
start,
|
||||
stop,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export function getAllPositions(line: string, regex: RegExp): number[] {
|
||||
let positions: number[] = [];
|
||||
const positions: number[] = [];
|
||||
let result = regex.exec(line);
|
||||
|
||||
while (result) {
|
||||
@ -17,7 +17,7 @@ export function getAllPositions(line: string, regex: RegExp): number[] {
|
||||
}
|
||||
|
||||
export function getAllEndPositions(line: string, regex: RegExp): number[] {
|
||||
let positions: number[] = [];
|
||||
const positions: number[] = [];
|
||||
let result = regex.exec(line);
|
||||
|
||||
while (result) {
|
||||
|
@ -89,11 +89,11 @@ export function getWordRight(
|
||||
inclusive: boolean = false
|
||||
): Position {
|
||||
for (let currentLine = pos.line; currentLine < TextEditor.getLineCount(); currentLine++) {
|
||||
let positions = getAllPositions(
|
||||
const positions = getAllPositions(
|
||||
TextEditor.getLine(currentLine).text,
|
||||
regexForWordType(wordType)
|
||||
);
|
||||
let newCharacter = positions.find(
|
||||
const newCharacter = positions.find(
|
||||
(index) =>
|
||||
(index > pos.character && !inclusive) ||
|
||||
(index >= pos.character && inclusive) ||
|
||||
@ -117,11 +117,11 @@ export function getCurrentWordEnd(
|
||||
inclusive: boolean = false
|
||||
): Position {
|
||||
for (let currentLine = pos.line; currentLine < TextEditor.getLineCount(); currentLine++) {
|
||||
let positions = getAllEndPositions(
|
||||
const positions = getAllEndPositions(
|
||||
TextEditor.getLine(currentLine).text,
|
||||
regexForWordType(wordType)
|
||||
);
|
||||
let newCharacter = positions.find(
|
||||
const newCharacter = positions.find(
|
||||
(index) =>
|
||||
(index > pos.character && !inclusive) ||
|
||||
(index >= pos.character && inclusive) ||
|
||||
@ -148,7 +148,7 @@ export function getLastWordEnd(pos: Position, wordType: WordType): Position {
|
||||
}
|
||||
// reverse the list to find the biggest element smaller than pos.character
|
||||
positions = positions.reverse();
|
||||
let index = positions.findIndex((i) => i < pos.character || currentLine !== pos.line);
|
||||
const index = positions.findIndex((i) => i < pos.character || currentLine !== pos.line);
|
||||
let newCharacter = 0;
|
||||
if (index === -1) {
|
||||
if (currentLine > -1) {
|
||||
@ -231,7 +231,7 @@ function makeUnicodeWordRegex(keywordChars: string): RegExp {
|
||||
// List of printable characters (code point intervals) and their character kinds.
|
||||
// Latin alphabets (e.g., ASCII alphabets and numbers, Latin-1 Supplement, European Latin) are excluded.
|
||||
// Imported from utf_class_buf in src/mbyte.c of Vim.
|
||||
const symbolTable: [[number, number], CharKind][] = [
|
||||
const symbolTable: Array<[[number, number], CharKind]> = [
|
||||
[[0x00a1, 0x00bf], CharKind.Punctuation], // Latin-1 punctuation
|
||||
[[0x037e, 0x037e], CharKind.Punctuation], // Greek question mark
|
||||
[[0x0387, 0x0387], CharKind.Punctuation], // Greek ano teleia
|
||||
@ -297,13 +297,13 @@ function makeUnicodeWordRegex(keywordChars: string): RegExp {
|
||||
];
|
||||
|
||||
const codePointRangePatterns: string[][] = [];
|
||||
for (let kind in CharKind) {
|
||||
for (const kind in CharKind) {
|
||||
if (!isNaN(Number(kind))) {
|
||||
codePointRangePatterns[kind] = [];
|
||||
}
|
||||
}
|
||||
|
||||
for (let [[first, last], kind] of symbolTable) {
|
||||
for (const [[first, last], kind] of symbolTable) {
|
||||
if (first === last) {
|
||||
// '\u{hhhh}'
|
||||
codePointRangePatterns[kind].push(`\\u{${first.toString(16)}}`);
|
||||
|
@ -292,7 +292,7 @@ export const isTextTransformation = (x: Transformation): x is TextTransformation
|
||||
x.type === 'moveCursor'
|
||||
);
|
||||
};
|
||||
export const isMultiCursorTextTransformation = (x: Transformation): Boolean => {
|
||||
export const isMultiCursorTextTransformation = (x: Transformation): boolean => {
|
||||
return (x.type === 'insertTextVSCode' && x.isMultiCursor) ?? false;
|
||||
};
|
||||
|
||||
@ -335,7 +335,7 @@ export const areAnyTransformationsOverlapping = (transformations: TextTransforma
|
||||
return false;
|
||||
};
|
||||
|
||||
export const areAllSameTransformation = (transformations: Transformation[]): Boolean => {
|
||||
export const areAllSameTransformation = (transformations: Transformation[]): boolean => {
|
||||
const firstTransformation = transformations[0];
|
||||
|
||||
return transformations.every((t) => {
|
||||
|
@ -51,7 +51,7 @@ export class Transformer {
|
||||
(x) => !isTextTransformation(x) && !isMultiCursorTextTransformation(x)
|
||||
);
|
||||
|
||||
let accumulatedPositionDifferences: { [key: number]: PositionDiff[] } = {};
|
||||
const accumulatedPositionDifferences: { [key: number]: PositionDiff[] } = {};
|
||||
|
||||
const doTextEditorEdit = (command: TextTransformations, edit: vscode.TextEditorEdit) => {
|
||||
switch (command.type) {
|
||||
@ -150,7 +150,7 @@ export class Transformer {
|
||||
break;
|
||||
|
||||
case 'showCommandHistory':
|
||||
let cmd = await commandLine.showHistory(vimState.currentCommandlineText);
|
||||
const cmd = await commandLine.showHistory(vimState.currentCommandlineText);
|
||||
if (cmd && cmd.length !== 0) {
|
||||
await commandLine.Run(cmd, vimState);
|
||||
modeHandler.updateView();
|
||||
@ -193,7 +193,7 @@ export class Transformer {
|
||||
break;
|
||||
|
||||
case 'macro':
|
||||
let recordedMacro = (await Register.get(vimState, transformation.register))?.text;
|
||||
const recordedMacro = (await Register.get(vimState, transformation.register))?.text;
|
||||
if (!(recordedMacro instanceof RecordedState)) {
|
||||
return;
|
||||
}
|
||||
@ -206,7 +206,7 @@ export class Transformer {
|
||||
await modeHandler.runMacro(recordedMacro);
|
||||
} else {
|
||||
let keyStrokes: string[] = [];
|
||||
for (let action of recordedMacro.actionsRun) {
|
||||
for (const action of recordedMacro.actionsRun) {
|
||||
keyStrokes = keyStrokes.concat(action.keysPressed);
|
||||
}
|
||||
vimState.recordedState = new RecordedState();
|
||||
|
@ -25,7 +25,7 @@ class ExternalCommand {
|
||||
* @param command the command to expand
|
||||
*/
|
||||
private expandCommand(command: string): string {
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
|
||||
for (let i = 0; i < command.length; i++) {
|
||||
if (command[i] === '!') {
|
||||
|
@ -137,7 +137,7 @@ export function getPathDetails(
|
||||
partialPath = untildify(partialPath);
|
||||
}
|
||||
|
||||
let [dirName, baseName] = separatePath(partialPath, p.sep);
|
||||
const [dirName, baseName] = separatePath(partialPath, p.sep);
|
||||
let fullDirPath: string;
|
||||
if (p.isAbsolute(dirName)) {
|
||||
fullDirPath = dirName;
|
||||
|
@ -8,7 +8,7 @@ import { Globals } from '../../src/globals';
|
||||
|
||||
suite('HistoryFile', () => {
|
||||
let history: HistoryFile;
|
||||
let run_cmds: string[];
|
||||
let runCmds: string[];
|
||||
|
||||
const assertArrayEquals = (expected: any[], actual: any[]) => {
|
||||
assert.strictEqual(expected.length, actual.length);
|
||||
@ -20,9 +20,9 @@ suite('HistoryFile', () => {
|
||||
setup(async () => {
|
||||
await setupWorkspace();
|
||||
|
||||
run_cmds = [];
|
||||
runCmds = [];
|
||||
for (let i = 0; i < configuration.history; i++) {
|
||||
run_cmds.push(i.toString());
|
||||
runCmds.push(i.toString());
|
||||
}
|
||||
|
||||
Globals.extensionStoragePath = os.tmpdir();
|
||||
@ -36,50 +36,50 @@ suite('HistoryFile', () => {
|
||||
});
|
||||
|
||||
test('add command', async () => {
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
assertArrayEquals(run_cmds.slice(), history.get());
|
||||
assertArrayEquals(runCmds.slice(), history.get());
|
||||
});
|
||||
|
||||
test('add empty command', async () => {
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
await history.add('');
|
||||
assertArrayEquals(run_cmds.slice(), history.get());
|
||||
assertArrayEquals(runCmds.slice(), history.get());
|
||||
await history.add(undefined);
|
||||
assertArrayEquals(run_cmds.slice(), history.get());
|
||||
assertArrayEquals(runCmds.slice(), history.get());
|
||||
});
|
||||
|
||||
test('add command over configuration.history', async () => {
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
const added_cmd: string = String(configuration.history);
|
||||
run_cmds.push(added_cmd);
|
||||
await history.add(added_cmd);
|
||||
const addedCmd: string = String(configuration.history);
|
||||
runCmds.push(addedCmd);
|
||||
await history.add(addedCmd);
|
||||
|
||||
assertArrayEquals(run_cmds.slice(1), history.get());
|
||||
assertArrayEquals(runCmds.slice(1), history.get());
|
||||
});
|
||||
|
||||
test('add command that exists in history', async () => {
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
const existed_cmd: string = '0';
|
||||
await history.add(existed_cmd);
|
||||
const expected_raw_history: string[] = run_cmds.slice();
|
||||
expected_raw_history.splice(expected_raw_history.indexOf(existed_cmd), 1);
|
||||
expected_raw_history.push(existed_cmd);
|
||||
assertArrayEquals(expected_raw_history, history.get());
|
||||
const existedCmd: string = '0';
|
||||
await history.add(existedCmd);
|
||||
const expectedRawHistory: string[] = runCmds.slice();
|
||||
expectedRawHistory.splice(expectedRawHistory.indexOf(existedCmd), 1);
|
||||
expectedRawHistory.push(existedCmd);
|
||||
assertArrayEquals(expectedRawHistory, history.get());
|
||||
});
|
||||
|
||||
test('file system', async () => {
|
||||
// history file is lazily created, should not exist
|
||||
assert.strictEqual(fs.existsSync(history.historyFilePath), false);
|
||||
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
|
||||
@ -93,17 +93,17 @@ suite('HistoryFile', () => {
|
||||
});
|
||||
|
||||
test('change configuration.history', async () => {
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
|
||||
assert.strictEqual(history.get().length, configuration.history);
|
||||
|
||||
configuration.history = 10;
|
||||
for (const cmd of run_cmds) {
|
||||
for (const cmd of runCmds) {
|
||||
await history.add(cmd);
|
||||
}
|
||||
|
||||
assertArrayEquals(run_cmds.slice(run_cmds.length - configuration.history), history.get());
|
||||
assertArrayEquals(runCmds.slice(runCmds.length - configuration.history), history.get());
|
||||
});
|
||||
});
|
||||
|
@ -12,8 +12,6 @@ import { getAndUpdateModeHandler } from '../../extension';
|
||||
import { VimState } from '../../src/state/vimState';
|
||||
import { StatusBar } from '../../src/statusBar';
|
||||
|
||||
/* tslint:disable:no-string-literal */
|
||||
|
||||
suite('Remapper', () => {
|
||||
let modeHandler: ModeHandler;
|
||||
let vimState: VimState;
|
||||
@ -613,22 +611,22 @@ suite('Remapper', () => {
|
||||
// act and assert
|
||||
|
||||
// check that 'ww' -> 'dw' waits for timeout to finish and timeout isn't run twice
|
||||
let result1: string[] = await new Promise(async (r1Resolve, r1Reject) => {
|
||||
let p1: Promise<string> = new Promise((p1Resolve, p1Reject) => {
|
||||
const result1: string[] = await new Promise(async (r1Resolve, r1Reject) => {
|
||||
const p1: Promise<string> = new Promise((p1Resolve, p1Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line after half timeout finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
p1Resolve(currentLine);
|
||||
}, timeout / 2);
|
||||
});
|
||||
let p2: Promise<string> = new Promise((p2Resolve, p2Reject) => {
|
||||
const p2: Promise<string> = new Promise((p2Resolve, p2Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line after timeout + offset finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
p2Resolve(currentLine);
|
||||
}, timeout + timeoutOffset);
|
||||
});
|
||||
let p3: Promise<string> = new Promise(async (p3Resolve, p3Reject) => {
|
||||
const p3: Promise<string> = new Promise(async (p3Resolve, p3Reject) => {
|
||||
await modeHandler.handleMultipleKeyEvents(['w', 'w']);
|
||||
p3Resolve('modeHandler.handleMultipleKeyEvents finished');
|
||||
});
|
||||
@ -647,25 +645,29 @@ suite('Remapper', () => {
|
||||
assert.strictEqual(result1[1], 'bar biz');
|
||||
|
||||
// check that 'www' -> 'dw' and then 'w' waits for timeout to finish
|
||||
let result2: { line: string; position: number }[] = await new Promise(
|
||||
const result2: Array<{ line: string; position: number }> = await new Promise(
|
||||
async (r2Resolve, r2Reject) => {
|
||||
let p1: Promise<{ line: string; position: number }> = new Promise((p1Resolve, p1Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line and cursor character after half timeout finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
const cursorCharacter = modeHandler.vimState.cursorStopPosition.character;
|
||||
p1Resolve({ line: currentLine, position: cursorCharacter });
|
||||
}, timeout / 2);
|
||||
});
|
||||
let p2: Promise<{ line: string; position: number }> = new Promise((p2Resolve, p2Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line and cursor character after timeout + offset finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
const cursorCharacter = modeHandler.vimState.cursorStopPosition.character;
|
||||
p2Resolve({ line: currentLine, position: cursorCharacter });
|
||||
}, timeout + timeoutOffset);
|
||||
});
|
||||
let p3: Promise<{ line: string; position: number }> = new Promise(
|
||||
const p1: Promise<{ line: string; position: number }> = new Promise(
|
||||
(p1Resolve, p1Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line and cursor character after half timeout finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
const cursorCharacter = modeHandler.vimState.cursorStopPosition.character;
|
||||
p1Resolve({ line: currentLine, position: cursorCharacter });
|
||||
}, timeout / 2);
|
||||
}
|
||||
);
|
||||
const p2: Promise<{ line: string; position: number }> = new Promise(
|
||||
(p2Resolve, p2Reject) => {
|
||||
setTimeout(() => {
|
||||
// get line and cursor character after timeout + offset finishes
|
||||
const currentLine = modeHandler.vimState.document.lineAt(0).text;
|
||||
const cursorCharacter = modeHandler.vimState.cursorStopPosition.character;
|
||||
p2Resolve({ line: currentLine, position: cursorCharacter });
|
||||
}, timeout + timeoutOffset);
|
||||
}
|
||||
);
|
||||
const p3: Promise<{ line: string; position: number }> = new Promise(
|
||||
async (p3Resolve, p3Reject) => {
|
||||
await modeHandler.handleMultipleKeyEvents(['w', 'w', 'w']);
|
||||
p3Resolve({ line: 'modeHandler.handleMultipleKeyEvents finished', position: -1 });
|
||||
@ -711,7 +713,7 @@ suite('Remapper', () => {
|
||||
);
|
||||
|
||||
// check that 'wwww' -> 'dd' doesn't wait for timeout
|
||||
let result3 = await new Promise(async (r3Resolve, r3Reject) => {
|
||||
const result3 = await new Promise(async (r3Resolve, r3Reject) => {
|
||||
const start = Number(new Date());
|
||||
|
||||
await modeHandler.handleMultipleKeyEvents(['w', 'w', 'w', 'w']).then(() => {
|
||||
@ -780,7 +782,7 @@ suite('Remapper', () => {
|
||||
// wait for 500 miliseconds (half of timeout) to simulate the time the user takes
|
||||
// between presses. Not using a fixed value here in case the default configuration
|
||||
// gets changed to use a lower value for timeout.
|
||||
let waited: boolean = await new Promise((wResolve, wReject) => {
|
||||
const waited: boolean = await new Promise((wResolve, wReject) => {
|
||||
setTimeout(() => {
|
||||
wResolve(true);
|
||||
}, timeout / 2);
|
||||
|
@ -4,7 +4,7 @@ import { ErrorCode, ErrorMessage } from '../src/error';
|
||||
|
||||
suite('Error', () => {
|
||||
test('error code has message', () => {
|
||||
/* tslint:disable:forin */
|
||||
// tslint:disable-next-line: forin
|
||||
for (const errorCodeString in ErrorCode) {
|
||||
const errorCode = Number(errorCodeString);
|
||||
if (!isNaN(errorCode)) {
|
||||
|
@ -19,7 +19,7 @@ suite('historyTracker unit tests', () => {
|
||||
const retrieveFileMark = (markName: string): IMark | undefined =>
|
||||
historyTracker.getGlobalMarks().find((mark) => mark.name === markName);
|
||||
|
||||
const setupVimState = () => <VimState>(<any>sandbox.createStubInstance(VimState));
|
||||
const setupVimState = () => (sandbox.createStubInstance(VimState) as unknown) as VimState;
|
||||
|
||||
const setupHistoryTracker = (vimState = setupVimState()) => new HistoryTracker(vimState);
|
||||
|
||||
@ -28,7 +28,7 @@ suite('historyTracker unit tests', () => {
|
||||
sandbox.stub(vscode, 'window').value({ activeTextEditor });
|
||||
};
|
||||
|
||||
const buildMockPosition = (): Position => <any>sandbox.createStubInstance(Position);
|
||||
const buildMockPosition = (): Position => sandbox.createStubInstance(Position) as any;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.createSandbox();
|
||||
|
@ -3229,7 +3229,7 @@ suite('Mode Normal', () => {
|
||||
|
||||
suite('marks', async () => {
|
||||
const jumpToNewFile = async () => {
|
||||
let configuration = new Configuration();
|
||||
const configuration = new Configuration();
|
||||
configuration.tabstop = 4;
|
||||
configuration.expandtab = false;
|
||||
await setupWorkspace(configuration);
|
||||
|
@ -353,7 +353,7 @@ suite('word motion', () => {
|
||||
});
|
||||
|
||||
suite('unicode word motion', () => {
|
||||
const text: Array<string> = [
|
||||
const text: string[] = [
|
||||
'漢字ひらがなカタカナalphabets、いろいろな文字。',
|
||||
'Καλημέρα κόσμε',
|
||||
'Die früh sich einst dem trüben Blick gezeigt.',
|
||||
@ -451,7 +451,7 @@ suite('unicode word motion', () => {
|
||||
});
|
||||
|
||||
suite('sentence motion', () => {
|
||||
const text: Array<string> = [
|
||||
const text: string[] = [
|
||||
'This text has many sections in it. What do you think?',
|
||||
'',
|
||||
'A paragraph boundary is also a sentence boundry, see',
|
||||
@ -532,7 +532,7 @@ suite('sentence motion', () => {
|
||||
});
|
||||
|
||||
suite('paragraph motion', () => {
|
||||
const text: Array<string> = [
|
||||
const text: string[] = [
|
||||
'this text has', // 0
|
||||
'', // 1
|
||||
'many', // 2
|
||||
|
@ -10,7 +10,6 @@ import { Configuration } from './testConfiguration';
|
||||
import { Globals } from '../src/globals';
|
||||
import { ValidatorResults } from '../src/configuration/iconfigurationValidator';
|
||||
import { IConfiguration } from '../src/configuration/iconfiguration';
|
||||
import { TextEditor } from '../src/textEditor';
|
||||
import { getAndUpdateModeHandler } from '../extension';
|
||||
import { commandLine } from '../src/cmd_line/commandLine';
|
||||
import { StatusBar } from '../src/statusBar';
|
||||
@ -29,7 +28,7 @@ class TestMemento implements vscode.Memento {
|
||||
}
|
||||
}
|
||||
export class TestExtensionContext implements vscode.ExtensionContext {
|
||||
subscriptions: { dispose(): any }[] = [];
|
||||
subscriptions: Array<{ dispose(): any }> = [];
|
||||
workspaceState: vscode.Memento = new TestMemento();
|
||||
globalState: vscode.Memento = new TestMemento();
|
||||
extensionPath: string = 'inmem:///test';
|
||||
|
50
tslint.json
50
tslint.json
@ -1,54 +1,16 @@
|
||||
{
|
||||
"extends": "tslint:recommended",
|
||||
"rules": {
|
||||
"align": false,
|
||||
"array-type": { "options": "array-simple" },
|
||||
"await-promise": [true, "Thenable"],
|
||||
"ban": false,
|
||||
"class-name": true,
|
||||
"comment-format": [true, "check-space"],
|
||||
"curly": true,
|
||||
"eofline": false,
|
||||
"forin": true,
|
||||
"indent": [true, "spaces"],
|
||||
"interface-name": false,
|
||||
"jsdoc-format": true,
|
||||
"label-position": true,
|
||||
"max-line-length": [true, 140],
|
||||
"member-access": false,
|
||||
"member-ordering": false,
|
||||
"no-any": false,
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-conditional-assignment": true,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"max-classes-per-file": false,
|
||||
"no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
|
||||
"no-construct": true,
|
||||
"no-parameter-properties": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-empty": true,
|
||||
"no-eval": true,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-null-keyword": false,
|
||||
"no-namespace": false,
|
||||
"no-parameter-properties": true,
|
||||
"no-return-await": true,
|
||||
"no-require-imports": false,
|
||||
"no-shadowed-variable": true,
|
||||
"no-string-literal": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-unnecessary-type-assertion": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": false,
|
||||
"no-var-keyword": true,
|
||||
"no-var-requires": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"prefer-for-of": true,
|
||||
"quotemark": false,
|
||||
"radix": true,
|
||||
"semicolon": [true, "always"],
|
||||
"switch-default": false,
|
||||
"triple-equals": [true, "allow-null-check"],
|
||||
"typedef": false,
|
||||
"variable-name": false
|
||||
"prefer-const": { "options": { "destructuring": "all" } }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user