mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
fix bad highlighting in view and terminal picker
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import nls = require('vs/nls');
|
||||
import errors = require('vs/base/common/errors');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import { Mode, IEntryRunContext, IAutoFocus, IQuickNavigateConfiguration, IModel } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { QuickOpenModel, QuickOpenEntryGroup, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { QuickOpenHandler, QuickOpenAction } from 'vs/workbench/browser/quickopen';
|
||||
@@ -18,6 +17,8 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { fuzzyContains, stripWildcards } from 'vs/base/common/strings';
|
||||
import { matchesFuzzy } from 'vs/base/common/filters';
|
||||
|
||||
export const VIEW_PICKER_PREFIX = 'view ';
|
||||
|
||||
@@ -73,7 +74,7 @@ export class ViewPickerHandler extends QuickOpenHandler {
|
||||
|
||||
public getResults(searchValue: string): TPromise<QuickOpenModel> {
|
||||
searchValue = searchValue.trim();
|
||||
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
|
||||
const normalizedSearchValueLowercase = stripWildcards(searchValue).toLowerCase();
|
||||
|
||||
const viewEntries = this.getViewEntries();
|
||||
|
||||
@@ -82,12 +83,14 @@ export class ViewPickerHandler extends QuickOpenHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strings.fuzzyContains(normalizedSearchValueLowercase, e.getLabel()) && !strings.fuzzyContains(normalizedSearchValueLowercase, e.getCategory())) {
|
||||
return false;
|
||||
const highlights = matchesFuzzy(normalizedSearchValueLowercase, e.getLabel(), true);
|
||||
if (highlights) {
|
||||
e.setHighlights(highlights);
|
||||
}
|
||||
|
||||
const { labelHighlights, descriptionHighlights } = QuickOpenEntry.highlight(e, searchValue);
|
||||
e.setHighlights(labelHighlights, descriptionHighlights);
|
||||
if (!highlights && !fuzzyContains(e.getCategory(), normalizedSearchValueLowercase)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
'use strict';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Mode, IEntryRunContext, IAutoFocus, IQuickNavigateConfiguration, IModel } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
@@ -13,6 +12,8 @@ import { QuickOpenHandler } from 'vs/workbench/browser/quickopen';
|
||||
import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
|
||||
import { stripWildcards } from 'vs/base/common/strings';
|
||||
import { matchesFuzzy } from 'vs/base/common/filters';
|
||||
|
||||
export class TerminalEntry extends QuickOpenEntry {
|
||||
|
||||
@@ -86,7 +87,7 @@ export class TerminalPickerHandler extends QuickOpenHandler {
|
||||
|
||||
public getResults(searchValue: string): TPromise<QuickOpenModel> {
|
||||
searchValue = searchValue.trim();
|
||||
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
|
||||
const normalizedSearchValueLowercase = stripWildcards(searchValue).toLowerCase();
|
||||
|
||||
const terminalEntries: QuickOpenEntry[] = this.getTerminals();
|
||||
terminalEntries.push(new CreateTerminal(nls.localize("'workbench.action.terminal.newplus", "$(plus) Create New Integrated Terminal"), this.terminalService));
|
||||
@@ -96,12 +97,12 @@ export class TerminalPickerHandler extends QuickOpenHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strings.fuzzyContains(normalizedSearchValueLowercase, e.getLabel())) {
|
||||
const highlights = matchesFuzzy(normalizedSearchValueLowercase, e.getLabel(), true);
|
||||
if (!highlights) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { labelHighlights, descriptionHighlights } = QuickOpenEntry.highlight(e, searchValue);
|
||||
e.setHighlights(labelHighlights, descriptionHighlights);
|
||||
e.setHighlights(highlights);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user