@@ -7,6 +7,7 @@ import { performance } from "perf_hooks";
77import * as p from "vscode-languageserver-protocol" ;
88import * as cp from "node:child_process" ;
99import semver from "semver" ;
10+ import * as os from "os" ;
1011import config , { send } from "./config" ;
1112import * as c from "./constants" ;
1213import { fileCodeActions } from "./codeActions" ;
@@ -555,6 +556,9 @@ function verifyTriggerToken(filePath: string, triggerToken: number): boolean {
555556 triggerToken
556557 ) ;
557558}
559+
560+ const isWindows = os . platform ( ) === "win32" ;
561+
558562async function figureOutBscArgs ( entry : IncrementallyCompiledFileInfo ) {
559563 const project = projectsFiles . get ( entry . project . rootPath ) ;
560564 if ( project ?. rescriptVersion == null ) {
@@ -591,10 +595,23 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
591595 buildArgs . forEach ( ( [ key , value ] : Array < string > ) => {
592596 if ( key === "-I" ) {
593597 if ( isBsb ) {
594- callArgs . push (
595- "-I" ,
596- path . resolve ( entry . project . rootPath , c . compilerDirPartialPath , value ) ,
597- ) ;
598+ /*build.ninja could have quoted paths on Windows
599+ Example:
600+ rule mij
601+ command = "C:\Users\moi\Projects\my-project\node_modules\rescript\win32\bsc.exe" -I src -I "C:\Users\moi\Projects\my-project\node_modules\@rescript\core\lib\ocaml" -open RescriptCore -uncurried -bs-package-name rewindow -bs-package-output esmodule:$in_d:.res.mjs -bs-v $g_finger $i
602+ */
603+ if ( isWindows && value . startsWith ( '"' ) && value . endsWith ( '"' ) ) {
604+ callArgs . push ( "-I" , value . substring ( 1 , value . length - 1 ) ) ;
605+ } else {
606+ callArgs . push (
607+ "-I" ,
608+ path . resolve (
609+ entry . project . rootPath ,
610+ c . compilerDirPartialPath ,
611+ value ,
612+ ) ,
613+ ) ;
614+ }
598615 } else {
599616 // TODO: once ReScript v12 is out we can remove this check for `.`
600617 if ( value === "." ) {
0 commit comments