Skip to content

Commit

Permalink
Do not let highlights decide on visiblity in result set
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 7, 2015
1 parent 3db61dd commit de8f289
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
15 changes: 3 additions & 12 deletions src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,10 @@ export class EditorHistoryModel extends QuickOpenModel {

// Apply highlights
const {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue);
if ((labelHighlights && labelHighlights.length) || (descriptionHighlights && descriptionHighlights.length)) {
results.push(entry.clone(labelHighlights, descriptionHighlights));
}
}

// If user is searching, use the same sorting that is used for other quick open handlers
if (searchValue) {
let normalizedSearchValue = strings.stripWildcards(searchValue.toLowerCase());

return results.sort((elementA: EditorHistoryEntry, elementB: EditorHistoryEntry) => QuickOpenEntry.compare(elementA, elementB, normalizedSearchValue));
results.push(entry.clone(labelHighlights, descriptionHighlights));
}

// Leave default "most recently used" order if user is not actually searching
return results;
// Sort
return results.sort((elementA: EditorHistoryEntry, elementB: EditorHistoryEntry) => QuickOpenEntry.compare(elementA, elementB, strings.stripWildcards(searchValue.toLowerCase())));
}
}
7 changes: 3 additions & 4 deletions src/vs/workbench/parts/search/browser/openAnythingHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ export class OpenAnythingHandler extends QuickOpenHandler {

// Apply highlights
const {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue);
if ((labelHighlights && labelHighlights.length) || (descriptionHighlights && descriptionHighlights.length)) {
entry.setHighlights(labelHighlights, descriptionHighlights);
results.push(entry);
}
entry.setHighlights(labelHighlights, descriptionHighlights);

results.push(entry);
}

// Sort
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/search/browser/openFileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export class OpenFileHandler extends QuickOpenHandler {
let description = labels.getPathLabel(paths.dirname(fileMatch.resource.fsPath), this.contextService);

let entry = this.instantiationService.createInstance(FileEntry, label, description, fileMatch.resource);

// Apply highlights
let {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue);
entry.setHighlights(labelHighlights, descriptionHighlights);

Expand Down

0 comments on commit de8f289

Please sign in to comment.