Skip to content

Commit

Permalink
cap visible entries in quick open
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 3, 2015
1 parent ef5fb3c commit dde70be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe

// Apply label to first entry
if (entries.length > 0) {
entries[0] = new QuickOpenEntryGroup(entries[0], nls.localize('historyMatches', "recently opened ({0})", entries.length), false);
entries[0] = new QuickOpenEntryGroup(entries[0], nls.localize('historyMatches', "recently opened"), false);
}

return new QuickOpenModel(entries, this.actionProvider);
Expand Down Expand Up @@ -623,7 +623,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
// Fill in history results if matching
let matchingHistoryEntries = this.editorHistoryModel.getResults(value);
if (matchingHistoryEntries.length > 0) {
matchingHistoryEntries[0] = new QuickOpenEntryGroup(matchingHistoryEntries[0], nls.localize('historyMatches', "recently opened ({0})", matchingHistoryEntries.length), false);
matchingHistoryEntries[0] = new QuickOpenEntryGroup(matchingHistoryEntries[0], nls.localize('historyMatches', "recently opened"), false);
}

let quickOpenModel = new QuickOpenModel(matchingHistoryEntries, this.actionProvider);
Expand Down Expand Up @@ -687,7 +687,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
// Show additional handler results below any existing results
if (additionalHandlerResults.length > 0) {
let useTopBorder = quickOpenModel.getEntries().length > 0;
additionalHandlerResults[0] = new QuickOpenEntryGroup(additionalHandlerResults[0], nls.localize('additionalResultsGroupLabel', "{0} ({1})", groupLabel, additionalHandlerResults.length), useTopBorder);
additionalHandlerResults[0] = new QuickOpenEntryGroup(additionalHandlerResults[0], nls.localize('additionalResultsGroupLabel', "{0}", groupLabel), useTopBorder);
quickOpenModel.addEntries(additionalHandlerResults);
this.quickOpenWidget.refresh(quickOpenModel, { autoFocusFirstEntry: true });
}
Expand Down
7 changes: 6 additions & 1 deletion src/vs/workbench/parts/search/browser/openAnythingHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class OpenAnythingHandler extends QuickOpenHandler {
private static SYMBOL_SEARCH_SUBSEQUENT_TIMEOUT = 100;
private static SEARCH_DELAY = 100; // This delay accommodates for the user typing a word and then stops typing to start searching

private static MAX_DISPLAYED_FILE_RESULTS = 2048;

private openSymbolHandler: _OpenSymbolHandler;
private openFileHandler: OpenFileHandler;
private resultsToSearchCache: { [searchValue: string]: QuickOpenEntry[]; };
Expand Down Expand Up @@ -150,7 +152,10 @@ export class OpenAnythingHandler extends QuickOpenHandler {
// Cache for fast lookup
this.resultsToSearchCache[searchValue] = result;

return TPromise.as<QuickOpenModel>(new QuickOpenModel(result));
// Cap the number of results to make the view snappy
const viewResults = result.slice(0, OpenAnythingHandler.MAX_DISPLAYED_FILE_RESULTS);

return TPromise.as<QuickOpenModel>(new QuickOpenModel(viewResults));
}, (error: Error) => {
this.pendingSearch = null;
this.messageService.show(Severity.Error, error);
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/parts/search/browser/openFileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export class OpenFileHandler extends QuickOpenHandler {
}

// Compare by name

let r = comparers.compareFileNames(elementAName, elementBName);
if (r !== 0) {
return r;
Expand Down

0 comments on commit dde70be

Please sign in to comment.