From 7b76b74e4cd7e740366f1f0ba2961e31b5f2ab95 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Tue, 21 Feb 2017 16:29:47 +0100 Subject: [PATCH] #20878 add string checks --- .../configuration-editing/src/settingsDocumentHelper.ts | 4 ++-- extensions/extension-editing/src/packageDocumentHelper.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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