Skip to content

Commit

Permalink
fix go to definition on windows (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetschwartz authored Jun 23, 2023
1 parent 91e3c81 commit 7caaad1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 12 additions & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
},
"dependencies": {
"@types/vscode": "^1.67.0",
"tmp": "^0.2.1",
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.8",
"tmp": "^0.2.1"
"vscode-uri": "^3.0.7"
},
"devDependencies": {
"@types/tmp": "^0.2.3"
Expand Down
11 changes: 6 additions & 5 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import {
Position,
} from "vscode-languageserver-protocol";

import { fileURLToPath } from "node:url";
import { TextEncoder } from "node:util";
import { TextDocument } from "vscode-languageserver-textdocument";
import { URI } from 'vscode-uri';


interface NuTextDocument extends TextDocument {
nuInlayHints?: InlayHint[];
Expand Down Expand Up @@ -58,9 +59,9 @@ let hasWorkspaceFolderCapability = false;
let hasDiagnosticRelatedInformationCapability = false;

function includeFlagForPath(file_path: string): string {
if (file_path.startsWith("file://")) {
file_path = decodeURI(file_path);
return "-I " + '"' + path.dirname(fileURLToPath(file_path));
const parsed = URI.parse(file_path);
if (parsed.scheme === "file") {
return "-I " + '"' + path.dirname(parsed.fsPath);
}
return "-I " + '"' + file_path;
}
Expand Down Expand Up @@ -614,7 +615,7 @@ async function goToDefinition(
if (obj.file == tmpFile.name) {
uri = document.uri;
} else {
uri = obj.file ? "file://" + obj.file : document.uri;
uri = obj.file ? URI.file(obj.file).toString() : document.uri;
}

// connection.console.log(uri);
Expand Down

0 comments on commit 7caaad1

Please sign in to comment.