diff --git a/src/mode/modes.ts b/src/mode/modes.ts index 35203bbfc8e..3670c80c56d 100644 --- a/src/mode/modes.ts +++ b/src/mode/modes.ts @@ -2,6 +2,8 @@ import { Position } from './../common/motion/position'; import { Mode, ModeName } from './mode'; import { VSCodeVimCursorType } from './mode'; import { VimState } from '../state/vimState'; +import { SearchDirection } from '../state/searchState'; +import { logger } from '../util/logger'; export enum VisualBlockInsertionType { /** @@ -63,7 +65,13 @@ export class SearchInProgressMode extends Mode { } getStatusBarText(vimState: VimState): string { - return `/${vimState.globalState.searchState!.searchString}`; + if (vimState.globalState.searchState === undefined) { + logger.error(`SearchInProgressMode.getStatusBarText: vimState.globalState.searchState is undefined.`); + return ''; + } + const leadingChar = + vimState.globalState.searchState.searchDirection === SearchDirection.Forward ? '/' : '?'; + return `${leadingChar}${vimState.globalState.searchState!.searchString}`; } getStatusBarCommandText(vimState: VimState): string { diff --git a/src/state/searchState.ts b/src/state/searchState.ts index d8967be4c07..ec957e400dd 100644 --- a/src/state/searchState.ts +++ b/src/state/searchState.ts @@ -36,6 +36,10 @@ export class SearchState { private _cachedDocumentVersion: number; private _cachedDocumentName: String; private _searchDirection: SearchDirection = SearchDirection.Forward; + public get searchDirection(): SearchDirection { + return this._searchDirection; + } + private isRegex: boolean; private _searchString = '';