diff --git a/server/src/server.ts b/server/src/server.ts index b82a799ee..8d6020cc2 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -617,7 +617,8 @@ function format(msg: p.RequestMessage): Array { } else { // code will always be defined here, even though technically it can be undefined let code = getOpenedFileContent(params.textDocument.uri); - let bscBinaryPath = findBscBinary(filePath); + let projectRootPath = utils.findProjectRootOfFile(filePath); + let bscBinaryPath = projectRootPath === null ? null : findBscBinary(projectRootPath); let formattedResult = utils.formatCode(bscBinaryPath, filePath, code); if (formattedResult.kind === "success") { let max = code.length;