From 96b405ff26ad23cb1af94983bc7b94daa24825d7 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Sat, 2 Jul 2022 23:05:54 +0200 Subject: [PATCH 1/2] Avoid crash if the document has errors --- workspace-d/source/workspaced/dparseext.d | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/workspace-d/source/workspaced/dparseext.d b/workspace-d/source/workspaced/dparseext.d index 99b99715..b418e807 100644 --- a/workspace-d/source/workspaced/dparseext.d +++ b/workspace-d/source/workspaced/dparseext.d @@ -309,7 +309,13 @@ string evaluateExpressionString(const Token token) case tok!"dstringLiteral": if (t.text.isStringLiteral) { - ret ~= unescapeString(t.text); + try { + ret ~= unescapeString(t.text); + } + catch (UTFException e) { + // document has errors + return str; + } } else { From 521230110692ec9183dabf22607569952f8a87cb Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Sat, 2 Jul 2022 23:08:32 +0200 Subject: [PATCH 2/2] Added the import for the exception --- workspace-d/source/workspaced/dparseext.d | 1 + 1 file changed, 1 insertion(+) diff --git a/workspace-d/source/workspaced/dparseext.d b/workspace-d/source/workspaced/dparseext.d index b418e807..bd54ec05 100644 --- a/workspace-d/source/workspaced/dparseext.d +++ b/workspace-d/source/workspaced/dparseext.d @@ -309,6 +309,7 @@ string evaluateExpressionString(const Token token) case tok!"dstringLiteral": if (t.text.isStringLiteral) { + import std.utf: UTFException; try { ret ~= unescapeString(t.text); }