From dcd82219d6913026dca29cbb8204bd9e81c0eef1 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Wed, 22 Nov 2023 10:34:32 -0800 Subject: [PATCH] fix: handle null setting description ranges (#198877) --- .../preferences/browser/preferencesSearch.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts b/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts index f4f730d4072..487f2fce94c 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts @@ -20,6 +20,7 @@ import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/ import { IAiRelatedInformationService, RelatedInformationType, SettingInformationResult } from 'vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation'; import { TfIdfCalculator, TfIdfDocument } from 'vs/base/common/tfIdf'; import { IStringDictionary } from 'vs/base/common/collections'; +import { nullRange } from 'vs/workbench/services/preferences/common/preferencesModels'; export interface IEndpointDetails { urlBase?: string; @@ -282,11 +283,17 @@ export class SettingMatches { } private toDescriptionRange(setting: ISetting, match: IMatch, lineIndex: number): IRange { + const descriptionRange = setting.descriptionRanges[lineIndex]; + if (!descriptionRange) { + // This case occurs with added settings such as the + // manage extension setting. + return nullRange; + } return { - startLineNumber: setting.descriptionRanges[lineIndex].startLineNumber, - startColumn: setting.descriptionRanges[lineIndex].startColumn + match.start, - endLineNumber: setting.descriptionRanges[lineIndex].endLineNumber, - endColumn: setting.descriptionRanges[lineIndex].startColumn + match.end + startLineNumber: descriptionRange.startLineNumber, + startColumn: descriptionRange.startColumn + match.start, + endLineNumber: descriptionRange.endLineNumber, + endColumn: descriptionRange.startColumn + match.end }; }