提交 677b68da 编写于 作者: B Benjamin Pasero

qick open - tweak delay and cancellation further

上级 0ee556cb
......@@ -37,8 +37,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
private static readonly LINE_COLON_PATTERN = /[#|:|\(](\d*)([#|:|,](\d*))?\)?$/;
private static readonly FILE_SEARCH_DELAY = 200;
private static readonly SYMBOL_SEARCH_DELAY = 500; // go easier on those symbols!
private static readonly TYPING_SEARCH_DELAY = 200; // This delay accommodates for the user typing a word and then stops typing to start searching
private static readonly MAX_DISPLAYED_RESULTS = 512;
......@@ -57,7 +56,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
super();
this.scorerCache = Object.create(null);
this.searchDelayer = new ThrottledDelayer<QuickOpenModel>(OpenAnythingHandler.FILE_SEARCH_DELAY);
this.searchDelayer = new ThrottledDelayer<QuickOpenModel>(OpenAnythingHandler.TYPING_SEARCH_DELAY);
this.openSymbolHandler = instantiationService.createInstance(OpenSymbolHandler);
this.openFileHandler = instantiationService.createInstance(OpenFileHandler);
......@@ -103,7 +102,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
}
// The throttler needs a factory for its promises
const promiseFactory = () => {
const resultsPromise = () => {
const resultPromises: TPromise<QuickOpenModel | FileQuickOpenModel>[] = [];
// File Results
......@@ -155,7 +154,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
};
// Trigger through delayer to prevent accumulation while the user is typing (except when expecting results to come from cache)
return this.hasShortResponseTime() ? promiseFactory() : this.searchDelayer.trigger(promiseFactory, this.includeSymbols ? OpenAnythingHandler.SYMBOL_SEARCH_DELAY : OpenAnythingHandler.FILE_SEARCH_DELAY);
return this.hasShortResponseTime() ? resultsPromise() : this.searchDelayer.trigger(resultsPromise, OpenAnythingHandler.TYPING_SEARCH_DELAY);
}
hasShortResponseTime(): boolean {
......
......@@ -15,7 +15,7 @@ import { IAutoFocus, Mode, IEntryRunContext } from 'vs/base/parts/quickopen/comm
import * as filters from 'vs/base/common/filters';
import * as strings from 'vs/base/common/strings';
import { Range } from 'vs/editor/common/core/range';
import { EditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { symbolKindToCssClass } from 'vs/editor/common/modes';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -71,10 +71,7 @@ class SymbolEntry extends EditorQuickOpenEntry {
run(mode: Mode, context: IEntryRunContext): boolean {
// resolve this type bearing if neccessary
if (!this.bearingResolve
&& typeof this.provider.resolveWorkspaceSymbol === 'function'
&& !this.bearing.location.range
) {
if (!this.bearingResolve && typeof this.provider.resolveWorkspaceSymbol === 'function' && !this.bearing.location.range) {
this.bearingResolve = Promise.resolve(this.provider.resolveWorkspaceSymbol(this.bearing, CancellationToken.None)).then(result => {
this.bearing = result || this.bearing;
......@@ -90,7 +87,7 @@ class SymbolEntry extends EditorQuickOpenEntry {
return mode === Mode.OPEN;
}
getInput(): IResourceInput | EditorInput {
getInput(): IResourceInput {
const input: IResourceInput = {
resource: this.bearing.location.uri,
options: {
......@@ -130,7 +127,7 @@ export class OpenSymbolHandler extends QuickOpenHandler {
static readonly ID = 'workbench.picker.symbols';
private static readonly SEARCH_DELAY = 200; // This delay accommodates for the user typing a word and then stops typing to start searching
private static readonly TYPING_SEARCH_DELAY = 200; // This delay accommodates for the user typing a word and then stops typing to start searching
private delayer: ThrottledDelayer<QuickOpenEntry[]>;
private options: IOpenSymbolOptions;
......@@ -138,7 +135,7 @@ export class OpenSymbolHandler extends QuickOpenHandler {
constructor(@IInstantiationService private instantiationService: IInstantiationService) {
super();
this.delayer = new ThrottledDelayer<QuickOpenEntry[]>(OpenSymbolHandler.SEARCH_DELAY);
this.delayer = new ThrottledDelayer<QuickOpenEntry[]>(OpenSymbolHandler.TYPING_SEARCH_DELAY);
this.options = Object.create(null);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册