mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Allow contributed configurations to define additional "search terms"
This commit is contained in:
@@ -200,6 +200,11 @@ export interface IConfigurationPropertySchema extends IJSONSchema {
|
||||
*/
|
||||
enumItemLabels?: string[];
|
||||
|
||||
/**
|
||||
* Optional terms used for search purposes.
|
||||
*/
|
||||
searchTerms?: string[];
|
||||
|
||||
/**
|
||||
* When specified, controls the presentation format of string settings.
|
||||
* Otherwise, the presentation format defaults to `singleline`.
|
||||
|
||||
@@ -116,6 +116,13 @@ const configurationEntrySchema: IJSONSchema = {
|
||||
type: 'boolean',
|
||||
description: nls.localize('scope.ignoreSync', 'When enabled, Settings Sync will not sync the user value of this configuration by default.')
|
||||
},
|
||||
searchTerms: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
description: nls.localize('scope.searchTerms', 'A list of additional search terms that help users find this setting in the Settings editor. These are not shown to the user.')
|
||||
},
|
||||
tags: {
|
||||
type: 'array',
|
||||
items: {
|
||||
|
||||
@@ -242,10 +242,13 @@ export class SettingMatches {
|
||||
// Search the description if we found non-contiguous key matches at best.
|
||||
const hasContiguousKeyMatchTypes = this.matchType >= SettingMatchType.ContiguousWordsInSettingsLabel;
|
||||
if (this.searchDescription && !hasContiguousKeyMatchTypes) {
|
||||
// Search the description lines and any additional search terms.
|
||||
const searchableLines = setting.searchTerms?.length
|
||||
? [...setting.description, setting.searchTerms.join(' ')]
|
||||
: setting.description;
|
||||
for (const word of queryWords) {
|
||||
// Search the description lines.
|
||||
for (let lineIndex = 0; lineIndex < setting.description.length; lineIndex++) {
|
||||
const descriptionMatches = matchesBaseContiguousSubString(word, setting.description[lineIndex]);
|
||||
for (let lineIndex = 0; lineIndex < searchableLines.length; lineIndex++) {
|
||||
const descriptionMatches = matchesBaseContiguousSubString(word, searchableLines[lineIndex]);
|
||||
if (descriptionMatches?.length) {
|
||||
descriptionMatchingWords.set(word, descriptionMatches.map(match => this.toDescriptionRange(setting, match, lineIndex)));
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface ISetting {
|
||||
value: any;
|
||||
valueRange: IRange;
|
||||
description: string[];
|
||||
searchTerms?: string[];
|
||||
descriptionIsMarkdown?: boolean;
|
||||
descriptionRanges: IRange[];
|
||||
overrides?: ISetting[];
|
||||
|
||||
@@ -723,6 +723,7 @@ export class DefaultSettings extends Disposable {
|
||||
value,
|
||||
description: descriptionLines,
|
||||
descriptionIsMarkdown: !!prop.markdownDescription,
|
||||
searchTerms: prop.searchTerms,
|
||||
range: nullRange,
|
||||
keyRange: nullRange,
|
||||
valueRange: nullRange,
|
||||
|
||||
Reference in New Issue
Block a user