Skip to content

Commit

Permalink
Make sure :noh disables hlsearch until the next search is done (#3749)
Browse files Browse the repository at this point in the history
Fixes #3748
  • Loading branch information
J-Fields authored and jpoon committed May 14, 2019
1 parent 8e57602 commit d3a5a03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ class CommandInsertInSearchMode extends BaseCommand {
const nextMatch = searchState.getNextSearchMatchPosition(vimState.cursorStopPosition);
vimState.cursorStopPosition = nextMatch.pos;

vimState.globalState.hl = true;

vimState.statusBarCursorCharacterPos = 0;
Register.putByKey(searchState.searchString, '/', undefined, true);

Expand Down Expand Up @@ -1311,8 +1313,6 @@ export class CommandSearchForwards extends BaseCommand {
// Reset search history index
vimState.globalState.searchStateIndex = vimState.globalState.searchStatePrevious.length;

vimState.globalState.hl = true;

return vimState;
}
}
Expand All @@ -1337,8 +1337,6 @@ export class CommandSearchBackwards extends BaseCommand {
// Reset search history index
vimState.globalState.searchStateIndex = vimState.globalState.searchStatePrevious.length;

vimState.globalState.hl = true;

return vimState;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/cmd_line/commands/nohl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { VimState } from '../../state/vimState';
import * as node from '../node';
import { StatusBar } from '../../statusBar';

export class NohlCommand extends node.CommandBase {
protected _arguments: {};
Expand All @@ -17,5 +18,8 @@ export class NohlCommand extends node.CommandBase {

async execute(vimState: VimState): Promise<void> {
vimState.globalState.hl = false;

// Clear the `match x of y` message from status bar
StatusBar.Set('', vimState.currentMode, vimState.isRecordingMacro, true);
}
}

0 comments on commit d3a5a03

Please sign in to comment.