From 2decf8da776e42ad2fd08fa273c863ba76cb03ad Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 28 Mar 2025 08:51:55 +0100 Subject: [PATCH 1/3] Use fs api to check if string is a directory. --- server/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/utils.ts b/server/src/utils.ts index 5de85abfc..551750ec3 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -67,7 +67,8 @@ export let findProjectRootOfFile = ( if (foundRootFromProjectFiles != null) { return foundRootFromProjectFiles; } else { - const isDir = path.extname(source) === ""; + const dirStat = fs.statSync(source); + const isDir = dirStat.isDirectory(); return findProjectRootOfFileInDir( isDir && !allowDir ? path.join(source, "dummy.res") : source ); From 481a8d2d3372c2c2e8af1c078c8c8998e6d849db Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 28 Mar 2025 09:03:06 +0100 Subject: [PATCH 2/3] Changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d09516c37..4b998cdcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ ## master +#### :bug: Bug fix + +- Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080 + ## 1.62.0 #### :nail_care: Polish From c4c1f6576f4f4f7b19199efffb03d42b5a165566 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 28 Mar 2025 09:33:46 +0100 Subject: [PATCH 3/3] Use findReScriptVersionForProjectRoot --- server/src/server.ts | 2 +- server/src/utils.ts | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index 1c74132e7..d7800c048 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -268,7 +268,7 @@ let openedFile = (fileUri: string, fileContent: string) => { filesDiagnostics: {}, namespaceName: namespaceName.kind === "success" ? namespaceName.result : null, - rescriptVersion: utils.findReScriptVersion(projectRootPath), + rescriptVersion: utils.findReScriptVersionForProjectRoot(projectRootPath), bsbWatcherByEditor: null, bscBinaryLocation: utils.findBscExeBinary(projectRootPath), editorAnalysisLocation: utils.findEditorAnalysisBinary(projectRootPath), diff --git a/server/src/utils.ts b/server/src/utils.ts index 551750ec3..a6dd745ef 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -67,8 +67,7 @@ export let findProjectRootOfFile = ( if (foundRootFromProjectFiles != null) { return foundRootFromProjectFiles; } else { - const dirStat = fs.statSync(source); - const isDir = dirStat.isDirectory(); + const isDir = path.extname(source) === ""; return findProjectRootOfFileInDir( isDir && !allowDir ? path.join(source, "dummy.res") : source ); @@ -166,6 +165,24 @@ export let findReScriptVersion = ( } }; +export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined { + let rescriptBinary = lookup.findFilePathFromProjectRoot( + projectRootPath, + path.join(c.nodeModulesBinDir, c.rescriptBinName) + ); + + if (rescriptBinary == null) { + return undefined; + } + + try { + let version = childProcess.execSync(`${rescriptBinary} -v`); + return version.toString().trim(); + } catch (e) { + return undefined; + } +} + // This is the path for the _builtin_ legacy analysis, that works for versions 11 and below. let builtinBinaryPath: string | null = null; if (fs.existsSync(c.builtinAnalysisDevPath)) {