Skip to content

Commit 892b600

Browse files
committed
Slightly better error messages
1 parent 8f90f81 commit 892b600

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/vimscript/exCommandParser.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,16 @@ export const exCommandParser: Parser<{ lineRange: LineRange | undefined; command
687687
);
688688
}
689689
const result = seq(parseArgs, optWhitespace.then(all)).parse(args);
690-
if (result.status === false || result.value[1]) {
691-
// TODO: All possible parsing errors are lumped into "trailing characters", which is wrong
690+
if (result.status === false) {
691+
if (result.index.offset === args.length) {
692+
throw VimError.fromCode(ErrorCode.ArgumentRequired);
693+
}
694+
throw VimError.fromCode(ErrorCode.InvalidArgument474);
695+
}
696+
if (result.value[1]) {
692697
// TODO: Implement `:help :bar`
693698
// TODO: Implement `:help :comment`
694-
throw VimError.fromCode(ErrorCode.TrailingCharacters);
699+
throw VimError.fromCode(ErrorCode.TrailingCharacters, result.value[1]);
695700
}
696701
return { lineRange, command: result.value[0] };
697702
});

test/vimscript/expression.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ suite('Vimscript expressions', () => {
426426
exprTest("'abc' ==? 'Abc'", { value: bool(true) });
427427
});
428428

429-
suite.only('Pattern matching', () => {
429+
suite('Pattern matching', () => {
430430
exprTest("'apple' =~ '^a.*e$'", { value: bool(true) });
431431
// TODO
432432
});
@@ -532,7 +532,7 @@ suite('Vimscript expressions', () => {
532532
});
533533

534534
suite('Builtin functions', () => {
535-
suite.only('assert_*', () => {
535+
suite('assert_*', () => {
536536
const PASS = { value: int(0) };
537537
const FAIL = { value: int(1) };
538538

0 commit comments

Comments
 (0)