diff --git a/extensions/configuration-editing/src/settingsDocumentHelper.ts b/extensions/configuration-editing/src/settingsDocumentHelper.ts index 8157bd0d483..e2d69c22318 100644 --- a/extensions/configuration-editing/src/settingsDocumentHelper.ts +++ b/extensions/configuration-editing/src/settingsDocumentHelper.ts @@ -160,7 +160,7 @@ export class SettingsDocument { // Suggestion model word matching includes quotes, // hence exclude the starting quote from the snippet and the range // ending quote gets replaced - if (text.startsWith('"')) { + if (text && text.startsWith('"')) { range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 1), range.end); snippet = snippet.substring(1); } @@ -173,7 +173,7 @@ export class SettingsDocument { })]); } - if (location.path.length === 1 && location.previousNode && location.previousNode.value.startsWith('[')) { + if (location.path.length === 1 && location.previousNode && typeof location.previousNode.value === 'string' && location.previousNode.value.startsWith('[')) { // Suggestion model word matching includes starting quote and open sqaure bracket // Hence exclude them from the proposal range diff --git a/extensions/extension-editing/src/packageDocumentHelper.ts b/extensions/extension-editing/src/packageDocumentHelper.ts index 95edcda721d..3fe0ba748e0 100644 --- a/extensions/extension-editing/src/packageDocumentHelper.ts +++ b/extensions/extension-editing/src/packageDocumentHelper.ts @@ -33,7 +33,7 @@ export class PackageDocument { // Suggestion model word matching includes quotes, // hence exclude the starting quote from the snippet and the range // ending quote gets replaced - if (text.startsWith('"')) { + if (text && text.startsWith('"')) { range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 1), range.end); snippet = snippet.substring(1); } @@ -46,7 +46,7 @@ export class PackageDocument { })]); } - if (location.path.length === 3 && location.previousNode && location.previousNode.value.startsWith('[')) { + if (location.path.length === 3 && location.previousNode && typeof location.previousNode.value === 'string' && location.previousNode.value.startsWith('[')) { // Suggestion model word matching includes starting quote and open sqaure bracket // Hence exclude them from the proposal range