Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for absolute paths using the workspace directory as the root #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,24 @@ class PeekFileDefinitionProvider implements vscode.DefinitionProvider {
if((position.character >= match_start) &&
(position.character <= match_end))
{
let full_path = path.resolve(working_dir, potential_fname);
let full_relative_path = path.resolve(working_dir, potential_fname);
let full_workspace_path= path.resolve(vscode.workspace.rootPath, potential_fname);
//console.log(" Match: ", match);
//console.log(" Fname: " + potential_fname);
//console.log(" Full: " + full_path);
//console.log(" Full Relative Path: " + full_relative_path);
//console.log(" Full Workspace Path: " + full_workspace_path);

// Find all potential paths to check and return the first one found
let potential_fnames = this.getPotentialPaths(full_path);
let potential_fnames = this.getPotentialPaths(full_relative_path);
potential_fnames = potential_fnames.concat(this.getPotentialPaths(full_workspace_path));
//console.log(" potential fnames: ", potential_fnames);

let found_fname = potential_fnames.find((fname_full) => {
//console.log(" checking: ", fname_full);
//console.log(" checking: ", fname_full);
return fs.existsSync(fname_full);
});
if (found_fname != null) {
console.log('found: ' + found_fname);
console.log('found: ' + found_fname);
return new vscode.Location(vscode.Uri.file(found_fname), new vscode.Position(0, 1));
}
}
Expand Down