Skip to content

Commit

Permalink
fix abs path ast
Browse files Browse the repository at this point in the history
  • Loading branch information
pizza-777 committed Sep 8, 2023
1 parent c6a821e commit 2d6f682
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ function searchPath(absolutePath) {
if (fs.existsSync(_path)) {
return _path;
}
const basePath = vscode.workspace.workspaceFolders[0].uri.fsPath;
const fromRoot = path.resolve(basePath, absolutePath).toLowerCase()// useful for win
if (fs.existsSync(fromRoot)) {
return fromRoot;
}
return ifBroxus(absolutePath);
}

Expand Down
11 changes: 8 additions & 3 deletions src/ast/findNodeByPosition.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require("path");
const vscode = require("vscode")

function findNodeByPosition(ast, position, document) {
for (let i = 0; i < ast.length; i++) {
Expand Down Expand Up @@ -62,11 +63,15 @@ function inRange(astPosition, position) {
return false;
}

function pathsAreEqual(path1, path2) {
function pathsAreEqual(path1, path2) {
const basePath = vscode.workspace.workspaceFolders[0].uri.fsPath;
//useful for win
if (path.resolve(basePath, path1).toLowerCase() === path2.toLowerCase()){
return true;
}
path1 = path.resolve(path1);
path2 = path.resolve(path2);
if (process.platform == "win32")
return path1.toLowerCase() === path2.toLowerCase();

return path1 === path2;
}

Expand Down

0 comments on commit 2d6f682

Please sign in to comment.