From 5d732b8c12d0ee4205650adab5f6390e72ac2154 Mon Sep 17 00:00:00 2001 From: Peter Schellenbach Date: Fri, 5 Jun 2020 15:58:53 -0700 Subject: [PATCH] Fix error processing customWordPath when last line is blank. May relate to #24. --- client/src/extension.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/extension.ts b/client/src/extension.ts index be19103..78424b5 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -125,10 +125,13 @@ export function activate(context: vscode.ExtensionContext) { var lines = contents.replace('\r', '').split('\n'); for (let i = 0; i < lines.length; i++) { let parts = lines[i].split(':') - customWordDict.set(parts[0].replace("\"", "").replace("\"", ""), parts[1].replace("\"", "").replace("\"", "")) - customWordlist += parts[0].replace('"', '').replace("\"", "") + "|"; + if (parts.length >= 2) { + customWordDict.set(parts[0].replace("\"", "").replace("\"", ""), parts[1].replace("\"", "").replace("\"", "")) + customWordlist += parts[0].replace("\"", '').replace("\"", "") + "|"; + } } - customWordlist = customWordlist.substr(0, customWordlist.length - 1) + ")"; + if (customWordlist.length > 1) + customWordlist = customWordlist.substr(0, customWordlist.length - 1) + ")"; }