diff --git a/extension.ts b/extension.ts index 5988e4eef29..258bb22766b 100644 --- a/extension.ts +++ b/extension.ts @@ -157,7 +157,7 @@ export async function activate(context: vscode.ExtensionContext) { // Delete modehandler once all tabs of this document have been closed for (let editorIdentity of ModeHandlerMap.getKeys()) { - let modeHandler = await ModeHandlerMap.get(editorIdentity); + const modeHandler = ModeHandlerMap.get(editorIdentity); if ( modeHandler == null || diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 77df8f02b8a..aa70d058bf7 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -1364,7 +1364,7 @@ export class PutCommand extends BaseCommand { }); return vimState; } else if (typeof register.text === 'object' && vimState.currentMode === ModeName.VisualBlock) { - return await this.execVisualBlockPaste(register.text, position, vimState, after); + return this.execVisualBlockPaste(register.text, position, vimState, after); } let text = await PutCommand.GetText(vimState, this.multicursorIndex); @@ -1478,9 +1478,7 @@ export class PutCommand extends BaseCommand { } else { if (text.indexOf('\n') === -1) { if (!position.isLineEnd()) { - if ( - register.registerMode === RegisterMode.BlockWise - ) { + if (register.registerMode === RegisterMode.BlockWise) { if (after) { diff = new PositionDiff(0, -1 * text.length); } else { @@ -1646,7 +1644,7 @@ export class PutWithIndentCommand extends BaseCommand { } public async execCount(position: Position, vimState: VimState): Promise { - return await super.execCount(position, vimState); + return super.execCount(position, vimState); } } @@ -2332,7 +2330,7 @@ class CommandDeleteToLineEnd extends BaseCommand { return vimState; } - return await new operator.DeleteOperator(this.multicursorIndex).run( + return new operator.DeleteOperator(this.multicursorIndex).run( vimState, position, position.getLineEnd().getLeft() @@ -2352,7 +2350,7 @@ export class CommandYankFullLine extends BaseCommand { vimState.currentRegisterMode = RegisterMode.LineWise; - return await new operator.YankOperator().run(vimState, start, end); + return new operator.YankOperator().run(vimState, start, end); } } @@ -2508,7 +2506,7 @@ class CommandSelectNextLastSearchWord extends BaseCommand { keys = ['g', 'n']; public async exec(position: Position, vimState: VimState): Promise { - return await selectLastSearchWord(vimState, SearchDirection.Forward); + return selectLastSearchWord(vimState, SearchDirection.Forward); } } @@ -2518,7 +2516,7 @@ class CommandSelectPreviousLastSearchWord extends BaseCommand { keys = ['g', 'N']; public async exec(position: Position, vimState: VimState): Promise { - return await selectLastSearchWord(vimState, SearchDirection.Backward); + return selectLastSearchWord(vimState, SearchDirection.Backward); } } @@ -3144,7 +3142,7 @@ class ActionDeleteCharWithDeleteKey extends BaseCommand { this.isCompleteAction = false; return vimState; } - return await new ActionDeleteChar().execCount(position, vimState); + return new ActionDeleteChar().execCount(position, vimState); } } @@ -3905,13 +3903,13 @@ class ActionDeleteLineVisualMode extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { if (vimState.currentMode === ModeName.Visual) { - return await new operator.DeleteOperator(this.multicursorIndex).run( + return new operator.DeleteOperator(this.multicursorIndex).run( vimState, vimState.cursorStartPosition.getLineBegin(), vimState.cursorPosition.getLineEnd() ); } else { - return await new operator.DeleteOperator(this.multicursorIndex).run( + return new operator.DeleteOperator(this.multicursorIndex).run( vimState, position.getLineBegin(), position.getLineEnd() @@ -3926,7 +3924,7 @@ class ActionChangeLineVisualMode extends BaseCommand { keys = ['C']; public async exec(position: Position, vimState: VimState): Promise { - return await new operator.DeleteOperator(this.multicursorIndex).run( + return new operator.DeleteOperator(this.multicursorIndex).run( vimState, vimState.cursorStartPosition.getLineBegin(), vimState.cursorPosition.getLineEndIncludingEOL() @@ -3940,7 +3938,7 @@ class ActionRemoveLineVisualMode extends BaseCommand { keys = ['R']; public async exec(position: Position, vimState: VimState): Promise { - return await new operator.DeleteOperator(this.multicursorIndex).run( + return new operator.DeleteOperator(this.multicursorIndex).run( vimState, vimState.cursorStartPosition.getLineBegin(), vimState.cursorPosition.getLineEndIncludingEOL() diff --git a/src/actions/commands/insert.ts b/src/actions/commands/insert.ts index 32793730e16..b492a2ba991 100644 --- a/src/actions/commands/insert.ts +++ b/src/actions/commands/insert.ts @@ -354,7 +354,7 @@ export class CommandOneNormalCommandInInsertMode extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { vimState.returnToInsertAfterCommand = true; - return await new CommandEscInsertMode().exec(position, vimState); + return new CommandEscInsertMode().exec(position, vimState); } } @RegisterAction diff --git a/src/actions/motion.ts b/src/actions/motion.ts index 9169521dc1b..4b38d79768a 100644 --- a/src/actions/motion.ts +++ b/src/actions/motion.ts @@ -113,7 +113,7 @@ export abstract class BaseMovement extends BaseAction { position: Position, vimState: VimState ): Promise { - return await this.execAction(position, vimState); + return this.execAction(position, vimState); } /** @@ -783,7 +783,7 @@ class MoveRepeat extends BaseMovement { ): Promise { const movement = VimState.lastSemicolonRepeatableMovement; if (movement) { - return await movement.execActionWithCount(position, vimState, count); + return movement.execActionWithCount(position, vimState, count); } return position; } @@ -800,7 +800,7 @@ class MoveRepeatReversed extends BaseMovement { ): Promise { const movement = VimState.lastCommaRepeatableMovement; if (movement) { - return await movement.execActionWithCount(position, vimState, count); + return movement.execActionWithCount(position, vimState, count); } return position; } @@ -1038,7 +1038,7 @@ class MoveToLineFromViewPortTop extends MoveByScreenLine { count: number ): Promise { this.value = count < 1 ? 1 : count; - return await this.execAction(position, vimState); + return this.execAction(position, vimState); } } @@ -1056,7 +1056,7 @@ class MoveToLineFromViewPortBottom extends MoveByScreenLine { count: number ): Promise { this.value = count < 1 ? 1 : count; - return await this.execAction(position, vimState); + return this.execAction(position, vimState); } } diff --git a/src/actions/operator.ts b/src/actions/operator.ts index 155f8971501..2c3de5198ac 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -234,7 +234,7 @@ export class DeleteOperatorVisual extends BaseOperator { // see special case in DeleteOperator.delete() vimState.currentRegisterMode = RegisterMode.LineWise; - return await new DeleteOperator(this.multicursorIndex).run(vimState, start, end); + return new DeleteOperator(this.multicursorIndex).run(vimState, start, end); } } @@ -314,7 +314,7 @@ export class ShiftYankOperatorVisual extends BaseOperator { public async run(vimState: VimState, start: Position, end: Position): Promise { vimState.currentRegisterMode = RegisterMode.LineWise; - return await new YankOperator().run(vimState, start, end); + return new YankOperator().run(vimState, start, end); } } @@ -324,7 +324,7 @@ export class DeleteOperatorXVisual extends BaseOperator { public modes = [ModeName.Visual, ModeName.VisualLine]; public async run(vimState: VimState, start: Position, end: Position): Promise { - return await new DeleteOperator(this.multicursorIndex).run(vimState, start, end); + return new DeleteOperator(this.multicursorIndex).run(vimState, start, end); } } @@ -339,7 +339,7 @@ export class ChangeOperatorSVisual extends BaseOperator { } public async run(vimState: VimState, start: Position, end: Position): Promise { - return await new ChangeOperator().run(vimState, start, end); + return new ChangeOperator().run(vimState, start, end); } } diff --git a/src/actions/textobject.ts b/src/actions/textobject.ts index 891bcc5ead0..96e919aad02 100644 --- a/src/actions/textobject.ts +++ b/src/actions/textobject.ts @@ -574,7 +574,7 @@ abstract class IndentObjectMatch extends TextObjectMovement { } public async execActionForOperator(position: Position, vimState: VimState): Promise { - return await this.execAction(position, vimState); + return this.execAction(position, vimState); } /** diff --git a/src/cmd_line/commands/read.ts b/src/cmd_line/commands/read.ts index 3a638b51ac0..ca98e0b8928 100644 --- a/src/cmd_line/commands/read.ts +++ b/src/cmd_line/commands/read.ts @@ -37,9 +37,9 @@ export class ReadCommand extends node.CommandBase { async getTextToInsert(): Promise { if (this.arguments.file && this.arguments.file.length > 0) { - return await this.getTextToInsertFromFile(); + return this.getTextToInsertFromFile(); } else if (this.arguments.cmd && this.arguments.cmd.length > 0) { - return await this.getTextToInsertFromCmd(); + return this.getTextToInsertFromCmd(); } else { throw Error('Invalid arguments'); } diff --git a/src/cmd_line/node.ts b/src/cmd_line/node.ts index dc16387e5c0..b3ddddca80e 100644 --- a/src/cmd_line/node.ts +++ b/src/cmd_line/node.ts @@ -215,9 +215,9 @@ export class CommandLine { } if (this.range.isEmpty) { - await this.command.execute(vimState); + this.command.execute(vimState); } else { - await this.command.executeWithRange(vimState, this.range); + this.command.executeWithRange(vimState, this.range); } } } diff --git a/src/register/register.ts b/src/register/register.ts index a1acdfef9ca..ecfbaa5e92d 100644 --- a/src/register/register.ts +++ b/src/register/register.ts @@ -337,7 +337,7 @@ export class Register { */ public static async get(vimState: VimState): Promise { const register = vimState.recordedState.registerName; - return await Register.getByKey(register, vimState); + return Register.getByKey(register, vimState); } public static async getByKey(register: string, vimState?: VimState): Promise { diff --git a/src/state/globalState.ts b/src/state/globalState.ts index 2622afbca9e..8ed6e8128a5 100644 --- a/src/state/globalState.ts +++ b/src/state/globalState.ts @@ -82,9 +82,9 @@ export class GlobalState { } } - public addNewSearchHistoryItem(searchString: string) { + public async addNewSearchHistoryItem(searchString: string) { if (GlobalState._searchHistory !== undefined) { - GlobalState._searchHistory.add(searchString); + await GlobalState._searchHistory.add(searchString); } } diff --git a/src/util/clipboard.ts b/src/util/clipboard.ts index f2d475c924a..377a0654dcf 100644 --- a/src/util/clipboard.ts +++ b/src/util/clipboard.ts @@ -11,6 +11,6 @@ export class Clipboard { } public static async Paste(): Promise { - return await vscode.env.clipboard.readText(); + return vscode.env.clipboard.readText(); } } diff --git a/tslint.json b/tslint.json index d1e887f384e..b07350cedd9 100644 --- a/tslint.json +++ b/tslint.json @@ -1,6 +1,7 @@ { "rules": { "align": false, + "await-promise": [true, "Thenable"], "ban": false, "class-name": true, "comment-format": [ @@ -45,6 +46,7 @@ "no-inferrable-types": false, "no-internal-module": false, "no-null-keyword": false, + "no-return-await": true, "no-require-imports": false, "no-shadowed-variable": true, "no-string-literal": true,