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

fix: incorrect file uri #58

Merged
merged 1 commit into from
Dec 28, 2024
Merged
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: 10 additions & 3 deletions server/src/lfortran-accessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ export class LFortranCLIAccessor implements LFortranAccessor {
this.logWarn("Failed to find file by URI: %s", filePath);
}

// if file name is `b.f90` then it will be replaced with `$(pwd)/b.f90`
// if file name is `a/b.f90` then it will be replaced with `$(pwd)/a/b.f90`

const newFilePath: string = path.resolve(filePath);
if (this.logger.isBenchmarkOrTraceEnabled()) {
this.logBenchmarkAndTrace(
fnid, start,
Expand All @@ -337,11 +341,11 @@ export class LFortranCLIAccessor implements LFortranAccessor {
"flags", flags,
"resolved", resolved,
],
filePath
newFilePath
);
}

return filePath;
return newFilePath;
}

async showDocumentSymbols(uri: string,
Expand Down Expand Up @@ -424,7 +428,7 @@ export class LFortranCLIAccessor implements LFortranAccessor {
const results: Record<string, any>[] = JSON.parse(stdout);
for (let i = 0, k = results.length; i < k; i++) {
const result: Record<string, any> = results[i];
const symbolPath: string =
let symbolPath: string =
this.resolve(result.filename, settings.compiler.flags);

const location = result.location;
Expand All @@ -439,6 +443,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {
end.line--;
end.character--;

if (symbolPath.endsWith(".tmp")) {
symbolPath = uri;
}
definitions.push({
targetUri: symbolPath,
targetRange: range,
Expand Down
Loading