提交 59213a4c 编写于 作者: J Jackson Kearl

Keep track of query includes/excludes expansion state

上级 f6f99313
......@@ -57,6 +57,7 @@ export class SearchEditor extends BaseEditor {
private runSearchDelayer = new Delayer(300);
private pauseSearching: boolean = false;
private showingIncludesExcludes: boolean = false;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
......@@ -82,7 +83,7 @@ export class SearchEditor extends BaseEditor {
this.queryEditorWidget = this._register(this.instantiationService.createInstance(SearchWidget, this.queryEditorContainer, { _hideReplaceToggle: true, showContextToggle: true }));
this._register(this.queryEditorWidget.onReplaceToggled(() => this.reLayout()));
this._register(this.queryEditorWidget.onDidHeightChange(() => this.reLayout()));
this.queryEditorWidget.onSearchSubmit(() => this.runSearch());
this.queryEditorWidget.onSearchSubmit(() => this.runSearch(true)); // onSearchSubmit has an internal delayer, so skip over ours.
this.queryEditorWidget.searchInput.onDidOptionChange(() => this.runSearch());
this.queryEditorWidget.onDidToggleContext(() => this.runSearch());
......@@ -92,14 +93,14 @@ export class SearchEditor extends BaseEditor {
this.toggleQueryDetailsButton = DOM.append(this.includesExcludesContainer, DOM.$('.expand.codicon.codicon-ellipsis', { tabindex: 0, role: 'button', title: localize('moreSearch', "Toggle Search Details") }));
this._register(DOM.addDisposableListener(this.toggleQueryDetailsButton, DOM.EventType.CLICK, e => {
DOM.EventHelper.stop(e);
this.toggleQueryDetails();
this.toggleIncludesExcludes();
}));
this._register(DOM.addDisposableListener(this.toggleQueryDetailsButton, DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
DOM.EventHelper.stop(e);
this.toggleQueryDetails();
this.toggleIncludesExcludes();
}
}));
this._register(DOM.addDisposableListener(this.toggleQueryDetailsButton, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
......@@ -159,9 +160,9 @@ export class SearchEditor extends BaseEditor {
});
}
private async runSearch() {
private async runSearch(instant = false) {
if (!this.pauseSearching) {
this.runSearchDelayer.trigger(() => this.doRunSearch());
this.runSearchDelayer.trigger(() => this.doRunSearch(), instant ? 0 : undefined);
}
}
......@@ -176,7 +177,8 @@ export class SearchEditor extends BaseEditor {
query: this.queryEditorWidget.searchInput.getValue(),
regexp: this.queryEditorWidget.searchInput.getRegex(),
wholeWord: this.queryEditorWidget.searchInput.getWholeWords(),
useIgnores: this.inputPatternExcludes.useExcludesAndIgnoreFiles()
useIgnores: this.inputPatternExcludes.useExcludesAndIgnoreFiles(),
showIncludesExcludes: this.showingIncludesExcludes
};
const content: IPatternInfo = {
......@@ -264,15 +266,16 @@ export class SearchEditor extends BaseEditor {
this.inputPatternExcludes.setValue(newInput.config.excludes);
this.inputPatternIncludes.setValue(newInput.config.includes);
this.inputPatternExcludes.setUseExcludesAndIgnoreFiles(newInput.config.useIgnores);
this.toggleIncludesExcludes(newInput.config.showIncludesExcludes);
this.focusInput();
await super.setInput(newInput, options, token);
this.pauseSearching = false;
}
toggleQueryDetails(): void {
private toggleIncludesExcludes(_shouldShow?: boolean): void {
const cls = 'expanded';
const shouldShow = !DOM.hasClass(this.includesExcludesContainer, cls);
const shouldShow = _shouldShow ?? !DOM.hasClass(this.includesExcludesContainer, cls);
if (shouldShow) {
this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'true');
......@@ -282,6 +285,8 @@ export class SearchEditor extends BaseEditor {
DOM.removeClass(this.includesExcludesContainer, cls);
}
this.showingIncludesExcludes = DOM.hasClass(this.includesExcludesContainer, cls);
this.reLayout();
}
......
......@@ -39,7 +39,8 @@ export type SearchConfiguration = {
wholeWord: boolean,
caseSensitive: boolean,
regexp: boolean,
useIgnores: boolean
useIgnores: boolean,
showIncludesExcludes: boolean,
};
let searchEditorInputInstances = 0;
......@@ -57,7 +58,7 @@ export class SearchEditorInput extends EditorInput {
super();
if (config === undefined) {
this.config = { query: '', includes: '', excludes: '', contextLines: 0, wholeWord: false, caseSensitive: false, regexp: false, useIgnores: true };
this.config = { query: '', includes: '', excludes: '', contextLines: 0, wholeWord: false, caseSensitive: false, regexp: false, useIgnores: true, showIncludesExcludes: false };
} else {
this.config = config;
}
......@@ -416,6 +417,7 @@ export const createEditorFromSearchResult =
excludes: rawExcludePattern,
contextLines: 0,
useIgnores: !searchResult.query.userDisabledExcludesAndIgnoreFiles,
showIncludesExcludes: !!(rawExcludePattern || rawExcludePattern || searchResult.query.userDisabledExcludesAndIgnoreFiles)
}),
{ pinned: true }) as SearchEditor;
......
......@@ -160,7 +160,6 @@ export class SearchWidget extends Widget {
private temporarilySkipSearchOnChange = false;
private showContextCheckbox!: Checkbox;
private contextLinesInput!: InputBox;
private _contextLineInputDelayer: Delayer<void>;
constructor(
container: HTMLElement,
......@@ -179,7 +178,6 @@ export class SearchWidget extends Widget {
this.replaceInputBoxFocused = Constants.ReplaceInputBoxFocusedKey.bindTo(this.contextKeyService);
this._replaceHistoryDelayer = new Delayer<void>(500);
this._contextLineInputDelayer = new Delayer<void>(300);
this._searchDelayer = this._register(new Delayer<void>(this.searchConfiguration.searchOnTypeDebouncePeriod));
this.render(container, options);
......@@ -386,7 +384,7 @@ export class SearchWidget extends Widget {
if (this.contextLinesInput.value.includes('-')) {
this.contextLinesInput.value = '0';
}
this._contextLineInputDelayer.trigger(() => this._onDidToggleContext.fire());
this._onDidToggleContext.fire();
}));
dom.append(searchInputContainer, this.showContextCheckbox.domNode);
}
......@@ -400,6 +398,7 @@ export class SearchWidget extends Widget {
this.showContextCheckbox.checked = true;
this.contextLinesInput.value = '' + lines;
}
dom.toggleClass(this.domNode, 'show-context', this.showContextCheckbox.checked);
}
private renderReplaceInput(parent: HTMLElement, options: ISearchWidgetOptions): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册