Allow contributed configurations to define additional "search terms"

This commit is contained in:
Matt Bierner
2026-02-10 12:21:40 -08:00
parent d4ee4a532a
commit 8efd494dc8
5 changed files with 20 additions and 3 deletions

View File

@@ -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`.

View File

@@ -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: {

View File

@@ -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)));
}

View File

@@ -64,6 +64,7 @@ export interface ISetting {
value: any;
valueRange: IRange;
description: string[];
searchTerms?: string[];
descriptionIsMarkdown?: boolean;
descriptionRanges: IRange[];
overrides?: ISetting[];

View File

@@ -723,6 +723,7 @@ export class DefaultSettings extends Disposable {
value,
description: descriptionLines,
descriptionIsMarkdown: !!prop.markdownDescription,
searchTerms: prop.searchTerms,
range: nullRange,
keyRange: nullRange,
valueRange: nullRange,