提交 a16e4326 编写于 作者: L Logan Ramos

Invert default direction

上级 b999cdbe
...@@ -26,7 +26,7 @@ const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next mat ...@@ -26,7 +26,7 @@ const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next mat
const NLS_CLOSE_BTN_LABEL = nls.localize('label.closeButton', "Close"); const NLS_CLOSE_BTN_LABEL = nls.localize('label.closeButton', "Close");
export abstract class SimpleFindWidget extends Widget { export abstract class SimpleFindWidget extends Widget {
private readonly _findInput: FindInput; protected readonly _findInput: FindInput;
private readonly _domNode: HTMLElement; private readonly _domNode: HTMLElement;
private readonly _innerDomNode: HTMLElement; private readonly _innerDomNode: HTMLElement;
private _isVisible: boolean = false; private _isVisible: boolean = false;
...@@ -36,15 +36,18 @@ export abstract class SimpleFindWidget extends Widget { ...@@ -36,15 +36,18 @@ export abstract class SimpleFindWidget extends Widget {
private prevBtn: SimpleButton; private prevBtn: SimpleButton;
private nextBtn: SimpleButton; private nextBtn: SimpleButton;
private foundMatch: boolean; private foundMatch: boolean;
private readonly _invertDefaultDirection: boolean | undefined;
constructor( constructor(
@IContextViewService private readonly _contextViewService: IContextViewService, @IContextViewService private readonly _contextViewService: IContextViewService,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
private readonly _state: FindReplaceState = new FindReplaceState(), private readonly _state: FindReplaceState = new FindReplaceState(),
showOptionButtons?: boolean showOptionButtons?: boolean,
invertDefaultDirection?: boolean
) { ) {
super(); super();
this._invertDefaultDirection = invertDefaultDirection;
this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewService, { this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewService, {
label: NLS_FIND_INPUT_LABEL, label: NLS_FIND_INPUT_LABEL,
placeholder: NLS_FIND_INPUT_PLACEHOLDER, placeholder: NLS_FIND_INPUT_PLACEHOLDER,
...@@ -93,13 +96,14 @@ export abstract class SimpleFindWidget extends Widget { ...@@ -93,13 +96,14 @@ export abstract class SimpleFindWidget extends Widget {
this._register(this._findInput.onKeyDown((e) => { this._register(this._findInput.onKeyDown((e) => {
if (e.equals(KeyCode.Enter)) { if (e.equals(KeyCode.Enter)) {
this.find(true); // Flip the direction search goes in the terminal case so it matches other terminals
this.find(this._invertDefaultDirection ? true : false);
e.preventDefault(); e.preventDefault();
return; return;
} }
if (e.equals(KeyMod.Shift | KeyCode.Enter)) { if (e.equals(KeyMod.Shift | KeyCode.Enter)) {
this.find(false); this.find(this._invertDefaultDirection ? false : true);
e.preventDefault(); e.preventDefault();
return; return;
} }
......
...@@ -8,7 +8,6 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView ...@@ -8,7 +8,6 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import { ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED } from 'vs/workbench/contrib/terminal/common/terminal'; import { ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED } from 'vs/workbench/contrib/terminal/common/terminal';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { FindReplaceState } from 'vs/editor/contrib/find/findState'; import { FindReplaceState } from 'vs/editor/contrib/find/findState';
export class TerminalFindWidget extends SimpleFindWidget { export class TerminalFindWidget extends SimpleFindWidget {
protected _findInputFocused: IContextKey<boolean>; protected _findInputFocused: IContextKey<boolean>;
protected _findWidgetFocused: IContextKey<boolean>; protected _findWidgetFocused: IContextKey<boolean>;
...@@ -19,7 +18,7 @@ export class TerminalFindWidget extends SimpleFindWidget { ...@@ -19,7 +18,7 @@ export class TerminalFindWidget extends SimpleFindWidget {
@IContextKeyService private readonly _contextKeyService: IContextKeyService, @IContextKeyService private readonly _contextKeyService: IContextKeyService,
@ITerminalService private readonly _terminalService: ITerminalService @ITerminalService private readonly _terminalService: ITerminalService
) { ) {
super(_contextViewService, _contextKeyService, findState, true); super(_contextViewService, _contextKeyService, findState, true, true);
this._register(findState.onFindReplaceStateChange(() => { this._register(findState.onFindReplaceStateChange(() => {
this.show(); this.show();
})); }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册