Skip to content

Commit 9596b49

Browse files
committed
Small refactor
1 parent 09a78e7 commit 9596b49

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/cmd_line/commands/vscode.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { VimError } from '../../error';
2-
import { StatusBar } from '../../statusBar';
32
import * as vscode from 'vscode';
43
import { VimState } from '../../state/vimState';
54
import { ExCommand } from '../../vimscript/exCommand';
@@ -10,18 +9,17 @@ export class VsCodeCommand extends ExCommand {
109
.then(all)
1110
.map((command) => new VsCodeCommand(command));
1211

13-
private command?: string;
12+
private command: string;
1413

15-
public constructor(command?: string) {
14+
public constructor(command: string) {
1615
super();
1716
this.command = command;
17+
if (!this.command) {
18+
throw VimError.ArgumentRequired();
19+
}
1820
}
1921

2022
async execute(vimState: VimState): Promise<void> {
21-
if (!this.command) {
22-
StatusBar.displayError(vimState, VimError.ArgumentRequired());
23-
return;
24-
}
2523
await vscode.commands.executeCommand(this.command);
2624
}
2725
}

test/vimscript/exCommandParse.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { VimError } from '../../src/error';
4343
import { EvalCommand } from '../../src/cmd_line/commands/eval';
4444
import { EchoCommand } from '../../src/cmd_line/commands/echo';
4545
import { Expression } from '../../src/vimscript/expression/types';
46+
import { VsCodeCommand } from '../../src/cmd_line/commands/vscode';
4647

4748
function exParseTest(input: string, parsed: ExCommand) {
4849
test(input, () => {
@@ -800,6 +801,14 @@ suite('Ex command parsing', () => {
800801
);
801802
});
802803

804+
suite(':vscode', () => {
805+
exParseTest(
806+
':vscode editor.action.commentLine',
807+
new VsCodeCommand('editor.action.commentLine'),
808+
);
809+
exParseFails(':vscode', VimError.ArgumentRequired());
810+
});
811+
803812
suite(':y[ank]', () => {
804813
exParseTest(':y', new YankCommand({ register: undefined, count: undefined }));
805814
exParseTest(':y a', new YankCommand({ register: 'a', count: undefined }));

0 commit comments

Comments
 (0)