From 7c6df11bd5b6d1a935eef5e98bef33caed5b64a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Mon, 29 Jul 2024 10:12:25 +0100 Subject: [PATCH] should not crash when the projectMapping fileRegex is set to a non existing file fixes #221 (#223) --- nimlangserver.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nimlangserver.nim b/nimlangserver.nim index 2702035..ea91f0e 100644 --- a/nimlangserver.nim +++ b/nimlangserver.nim @@ -283,8 +283,9 @@ proc getProjectFile(fileUri: string, ls: LanguageServer): Future[string] {.async for mapping in mappings: if find(cstring(pathRelativeToRoot), re(mapping.fileRegex), 0, pathRelativeToRoot.len) != -1: result = string(rootPath) / mapping.projectFile - trace "getProjectFile", project = result, uri = fileUri, matchedRegex = mapping.fileRegex - return result + if fileExists(result): + trace "getProjectFile", project = result, uri = fileUri, matchedRegex = mapping.fileRegex + return result else: trace "getProjectFile does not match", uri = fileUri, matchedRegex = mapping.fileRegex