Only delay progress indicator when triggered on type
This commit is contained in:
parent
8e7877bdc4
commit
b9ca01d9c2
4 changed files with 22 additions and 22 deletions
|
@ -43,8 +43,8 @@ export class PatternInputWidget extends Widget {
|
|||
private domNode!: HTMLElement;
|
||||
protected inputBox!: HistoryInputBox;
|
||||
|
||||
private _onSubmit = this._register(new Emitter<void>());
|
||||
onSubmit: CommonEvent<void> = this._onSubmit.event;
|
||||
private _onSubmit = this._register(new Emitter<boolean>());
|
||||
onSubmit: CommonEvent<boolean /* triggeredOnType */> = this._onSubmit.event;
|
||||
|
||||
private _onCancel = this._register(new Emitter<void>());
|
||||
onCancel: CommonEvent<void> = this._onCancel.event;
|
||||
|
@ -152,7 +152,7 @@ export class PatternInputWidget extends Widget {
|
|||
this._register(this.inputBox.onDidChange(() => {
|
||||
if (this.searchConfig.searchOnType) {
|
||||
this._onCancel.fire();
|
||||
this.searchOnTypeDelayer.trigger(() => this._onSubmit.fire(), this.searchConfig.searchOnTypeDebouncePeriod);
|
||||
this.searchOnTypeDelayer.trigger(() => this._onSubmit.fire(false), this.searchConfig.searchOnTypeDebouncePeriod);
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -170,7 +170,7 @@ export class PatternInputWidget extends Widget {
|
|||
private onInputKeyUp(keyboardEvent: IKeyboardEvent) {
|
||||
switch (keyboardEvent.keyCode) {
|
||||
case KeyCode.Enter:
|
||||
this._onSubmit.fire();
|
||||
this._onSubmit.fire(true);
|
||||
return;
|
||||
case KeyCode.Escape:
|
||||
this._onCancel.fire();
|
||||
|
|
|
@ -275,7 +275,7 @@ export class RefreshAction extends Action {
|
|||
run(): Promise<void> {
|
||||
const searchView = getSearchView(this.viewletService, this.panelService);
|
||||
if (searchView) {
|
||||
searchView.onQueryChanged();
|
||||
searchView.onQueryChanged(false);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
|
|
|
@ -268,7 +268,7 @@ export class SearchView extends ViewletPanel {
|
|||
|
||||
this.inputPatternIncludes.setValue(patternIncludes);
|
||||
|
||||
this.inputPatternIncludes.onSubmit(() => this.onQueryChanged(true));
|
||||
this.inputPatternIncludes.onSubmit(triggeredOnType => this.onQueryChanged(true, triggeredOnType));
|
||||
this.inputPatternIncludes.onCancel(() => this.cancelSearch(false));
|
||||
this.trackInputBox(this.inputPatternIncludes.inputFocusTracker, this.inputPatternIncludesFocused);
|
||||
|
||||
|
@ -284,7 +284,7 @@ export class SearchView extends ViewletPanel {
|
|||
this.inputPatternExcludes.setValue(patternExclusions);
|
||||
this.inputPatternExcludes.setUseExcludesAndIgnoreFiles(useExcludesAndIgnoreFiles);
|
||||
|
||||
this.inputPatternExcludes.onSubmit(() => this.onQueryChanged(true));
|
||||
this.inputPatternExcludes.onSubmit(triggeredOnType => this.onQueryChanged(true, triggeredOnType));
|
||||
this.inputPatternExcludes.onCancel(() => this.cancelSearch(false));
|
||||
this.inputPatternExcludes.onChangeIgnoreBox(() => this.onQueryChanged(true));
|
||||
this.trackInputBox(this.inputPatternExcludes.inputFocusTracker, this.inputPatternExclusionsFocused);
|
||||
|
@ -386,7 +386,7 @@ export class SearchView extends ViewletPanel {
|
|||
this.searchWidget.toggleReplace(true);
|
||||
}
|
||||
|
||||
this._register(this.searchWidget.onSearchSubmit(() => this.onQueryChanged()));
|
||||
this._register(this.searchWidget.onSearchSubmit(triggeredOnType => this.onQueryChanged(false, triggeredOnType)));
|
||||
this._register(this.searchWidget.onSearchCancel(({ focus }) => this.cancelSearch(focus)));
|
||||
this._register(this.searchWidget.searchInput.onDidOptionChange(() => this.onQueryChanged(true)));
|
||||
|
||||
|
@ -800,7 +800,7 @@ export class SearchView extends ViewletPanel {
|
|||
}
|
||||
this.searchWidget.setValue(selectedText, true);
|
||||
updatedText = true;
|
||||
this.onQueryChanged();
|
||||
this.onQueryChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ export class SearchView extends ViewletPanel {
|
|||
this.searchWidget.focus(false);
|
||||
}
|
||||
|
||||
onQueryChanged(preserveFocus?: boolean): void {
|
||||
onQueryChanged(preserveFocus: boolean, triggeredOnType = false): void {
|
||||
if (!this.searchWidget.searchInput.inputBox.isInputValid()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ export class SearchView extends ViewletPanel {
|
|||
}
|
||||
|
||||
this.validateQuery(query).then(() => {
|
||||
this.onQueryTriggered(query, options, excludePatternText, includePatternText);
|
||||
this.onQueryTriggered(query, options, excludePatternText, includePatternText, triggeredOnType);
|
||||
|
||||
if (!preserveFocus) {
|
||||
this.searchWidget.focus(false); // focus back to input field
|
||||
|
@ -1251,7 +1251,7 @@ export class SearchView extends ViewletPanel {
|
|||
});
|
||||
}
|
||||
|
||||
private onQueryTriggered(query: ITextQuery, options: ITextQueryBuilderOptions, excludePatternText: string, includePatternText: string): void {
|
||||
private onQueryTriggered(query: ITextQuery, options: ITextQueryBuilderOptions, excludePatternText: string, includePatternText: string, triggeredOnType: boolean): void {
|
||||
this.addToSearchHistoryDelayer.trigger(() => this.searchWidget.searchInput.onSearchSubmit());
|
||||
this.inputPatternExcludes.onSearchSubmit();
|
||||
this.inputPatternIncludes.onSearchSubmit();
|
||||
|
@ -1259,13 +1259,13 @@ export class SearchView extends ViewletPanel {
|
|||
this.viewModel.cancelSearch();
|
||||
|
||||
this.currentSearchQ = this.currentSearchQ
|
||||
.then(() => this.doSearch(query, options, excludePatternText, includePatternText))
|
||||
.then(() => this.doSearch(query, options, excludePatternText, includePatternText, triggeredOnType))
|
||||
.then(() => undefined, () => undefined);
|
||||
}
|
||||
|
||||
private doSearch(query: ITextQuery, options: ITextQueryBuilderOptions, excludePatternText: string, includePatternText: string): Thenable<void> {
|
||||
private doSearch(query: ITextQuery, options: ITextQueryBuilderOptions, excludePatternText: string, includePatternText: string, triggeredOnType: boolean): Thenable<void> {
|
||||
let progressComplete: () => void;
|
||||
this.progressService.withProgress({ location: VIEWLET_ID, delay: 300 }, _progress => {
|
||||
this.progressService.withProgress({ location: VIEWLET_ID, delay: triggeredOnType ? 300 : 0 }, _progress => {
|
||||
return new Promise(resolve => progressComplete = resolve);
|
||||
});
|
||||
|
||||
|
@ -1335,7 +1335,7 @@ export class SearchView extends ViewletPanel {
|
|||
const searchAgainLink = dom.append(p, $('a.pointer.prominent', undefined, nls.localize('rerunSearch.message', "Search again")));
|
||||
this.messageDisposables.push(dom.addDisposableListener(searchAgainLink, dom.EventType.CLICK, (e: MouseEvent) => {
|
||||
dom.EventHelper.stop(e, false);
|
||||
this.onQueryChanged();
|
||||
this.onQueryChanged(false);
|
||||
}));
|
||||
} else if (hasIncludes || hasExcludes) {
|
||||
const searchAgainLink = dom.append(p, $('a.pointer.prominent', { tabindex: 0 }, nls.localize('rerunSearchInAll.message', "Search again in all files")));
|
||||
|
@ -1345,7 +1345,7 @@ export class SearchView extends ViewletPanel {
|
|||
this.inputPatternExcludes.setValue('');
|
||||
this.inputPatternIncludes.setValue('');
|
||||
|
||||
this.onQueryChanged();
|
||||
this.onQueryChanged(false);
|
||||
}));
|
||||
} else {
|
||||
const openSettingsLink = dom.append(p, $('a.pointer.prominent', { tabindex: 0 }, nls.localize('openSettings.message', "Open Settings")));
|
||||
|
|
|
@ -121,8 +121,8 @@ export class SearchWidget extends Widget {
|
|||
private ignoreGlobalFindBufferOnNextFocus = false;
|
||||
private previousGlobalFindBufferValue: string | null = null;
|
||||
|
||||
private _onSearchSubmit = this._register(new Emitter<void>());
|
||||
readonly onSearchSubmit: Event<void> = this._onSearchSubmit.event;
|
||||
private _onSearchSubmit = this._register(new Emitter<boolean>());
|
||||
readonly onSearchSubmit: Event<boolean /* triggeredOnType */> = this._onSearchSubmit.event;
|
||||
|
||||
private _onSearchCancel = this._register(new Emitter<{ focus: boolean }>());
|
||||
readonly onSearchCancel: Event<{ focus: boolean }> = this._onSearchCancel.event;
|
||||
|
@ -454,7 +454,7 @@ export class SearchWidget extends Widget {
|
|||
this.temporarilySkipSearchOnChange = false;
|
||||
} else {
|
||||
this._onSearchCancel.fire({ focus: false });
|
||||
this._searchDelayer.trigger((() => this.submitSearch()), this.searchConfiguration.searchOnTypeDebouncePeriod);
|
||||
this._searchDelayer.trigger((() => this.submitSearch(true)), this.searchConfiguration.searchOnTypeDebouncePeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ export class SearchWidget extends Widget {
|
|||
}
|
||||
}
|
||||
|
||||
private submitSearch(): void {
|
||||
private submitSearch(triggeredOnType = false): void {
|
||||
this.searchInput.validate();
|
||||
if (!this.searchInput.inputBox.isInputValid()) {
|
||||
return;
|
||||
|
@ -574,7 +574,7 @@ export class SearchWidget extends Widget {
|
|||
if (value && useGlobalFindBuffer) {
|
||||
this.clipboardServce.writeFindText(value);
|
||||
}
|
||||
this._onSearchSubmit.fire();
|
||||
this._onSearchSubmit.fire(triggeredOnType);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
|
|
Loading…
Reference in a new issue