Skip to content

Commit 3e96126

Browse files
committed
Fix definition files absolute path not working on windows
1 parent 768ccb6 commit 3e96126

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2727
- Document symbols for method definitions now correctly use a colon instead of a dot operator.
2828
- Fixed crash when hovering over a type node
2929
- Fixed go to definition on a global just going to the top of the file. It will now not accept go to definition requests
30+
- Fixed using absolute file paths to point to definition files not working on Windows
3031

3132
## [1.6.0] - 2022-07-02
3233

editors/code/package-lock.json

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editors/code/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@
184184
},
185185
"dependencies": {
186186
"node-fetch": "^3.2.4",
187-
"vscode-languageclient": "^8.0.2-next.5",
188-
"vscode-uri": "^3.0.3"
187+
"vscode-languageclient": "^8.0.2-next.5"
189188
}
190-
}
189+
}

editors/code/src/extension.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from "vscode";
22
import * as os from "os";
3+
import * as path from "path";
34
import fetch from "node-fetch";
45
import {
56
Executable,
@@ -8,8 +9,6 @@ import {
89
LanguageClientOptions,
910
} from "vscode-languageclient/node";
1011

11-
import { Utils as UriUtils } from "vscode-uri";
12-
1312
import spawn from "./spawn";
1413

1514
let client: LanguageClient;
@@ -41,6 +40,14 @@ const exists = (uri: vscode.Uri): Thenable<boolean> => {
4140
);
4241
};
4342

43+
const basenameUri = (uri: vscode.Uri): string => {
44+
return path.basename(uri.fsPath);
45+
};
46+
47+
const resolveUri = (uri: vscode.Uri, ...paths: string[]): vscode.Uri => {
48+
return vscode.Uri.file(path.resolve(uri.fsPath, ...paths));
49+
};
50+
4451
const downloadApiDefinitions = async (context: vscode.ExtensionContext) => {
4552
try {
4653
return vscode.window.withProgress(
@@ -127,7 +134,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
127134
// Check if the project file exists
128135
let projectFile =
129136
config.get<string>("rojoProjectFile") ?? "default.project.json";
130-
const projectFileUri = UriUtils.resolvePath(workspaceFolder.uri, projectFile);
137+
const projectFileUri = resolveUri(workspaceFolder.uri, projectFile);
131138

132139
if (!(await exists(projectFileUri))) {
133140
// Search if there is a *.project.json file present in this workspace.
@@ -141,7 +148,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
141148
);
142149
return;
143150
} else if (foundProjectFiles.length === 1) {
144-
const fileName = UriUtils.basename(foundProjectFiles[0]);
151+
const fileName = basenameUri(foundProjectFiles[0]);
145152
const option = await vscode.window.showWarningMessage(
146153
`Unable to find project file ${projectFile}. We found ${fileName} available`,
147154
`Set project file to ${fileName}`,
@@ -161,7 +168,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
161168
"Cancel"
162169
);
163170
if (option === "Select project file") {
164-
const files = foundProjectFiles.map((file) => UriUtils.basename(file));
171+
const files = foundProjectFiles.map((file) => basenameUri(file));
165172
const selectedFile = await vscode.window.showQuickPick(files);
166173
if (selectedFile) {
167174
config.update("rojoProjectFile", selectedFile);
@@ -223,7 +230,7 @@ export async function activate(context: vscode.ExtensionContext) {
223230
for (const definitionPath of definitionFiles) {
224231
let uri;
225232
if (vscode.workspace.workspaceFolders) {
226-
uri = UriUtils.resolvePath(
233+
uri = resolveUri(
227234
vscode.workspace.workspaceFolders[0].uri,
228235
definitionPath
229236
);

0 commit comments

Comments
 (0)