Skip to content

Commit 7c6df11

Browse files
authored
should not crash when the projectMapping fileRegex is set to a non existing file fixes #221 (#223)
1 parent 69e94dd commit 7c6df11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nimlangserver.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ proc getProjectFile(fileUri: string, ls: LanguageServer): Future[string] {.async
283283
for mapping in mappings:
284284
if find(cstring(pathRelativeToRoot), re(mapping.fileRegex), 0, pathRelativeToRoot.len) != -1:
285285
result = string(rootPath) / mapping.projectFile
286-
trace "getProjectFile", project = result, uri = fileUri, matchedRegex = mapping.fileRegex
287-
return result
286+
if fileExists(result):
287+
trace "getProjectFile", project = result, uri = fileUri, matchedRegex = mapping.fileRegex
288+
return result
288289
else:
289290
trace "getProjectFile does not match", uri = fileUri, matchedRegex = mapping.fileRegex
290291

0 commit comments

Comments
 (0)