Skip to content

Commit 0791d2a

Browse files
committed
adds focus on the first search result when running vimgrep without the j flag
1 parent 8b0a5d6 commit 0791d2a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cmd_line/commands/grep.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ interface IGrepCommandArguments {
2828
// Implements :grep
2929
// https://vimdoc.sourceforge.net/htmldoc/quickfix.html#:vimgrep
3030
export class GrepCommand extends ExCommand {
31+
// TODO: pattern match the entire command to see if there are slashes and a flag to determine what to parse
3132
public static readonly argParser: Parser<GrepCommand> = optWhitespace.then(
3233
seq(
33-
Pattern.parser({ direction: SearchDirection.Backward, delimiter: ' ' }),
34-
34+
Pattern.parser({ direction: SearchDirection.Backward, delimiter: '' }),
3535
fileNameParser.sepBy(whitespace),
3636
).map(([pattern, files]) => new GrepCommand({ pattern, files })),
3737
);
@@ -64,6 +64,8 @@ export class GrepCommand extends ExCommand {
6464
isRegex: true,
6565
});
6666
await vscode.commands.executeCommand('search.action.focusSearchList');
67+
// Only if there's no [j] flag
68+
await vscode.commands.executeCommand('search.action.focusNextSearchResult');
6769
// TODO: this will always throw an error, since the command returns nothing
6870
// if (!grepResults) {
6971
// throw error.VimError.fromCode(error.ErrorCode.PatternNotFound);

0 commit comments

Comments
 (0)