From ddb3925f75fc426eba052185390d6fcdeb26bfc3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 28 Dec 2024 12:28:48 +0530 Subject: [PATCH] fix: incorrect file uri --- server/src/lfortran-accessors.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/lfortran-accessors.ts b/server/src/lfortran-accessors.ts index 4c01604..99bd2f4 100644 --- a/server/src/lfortran-accessors.ts +++ b/server/src/lfortran-accessors.ts @@ -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, @@ -337,11 +341,11 @@ export class LFortranCLIAccessor implements LFortranAccessor { "flags", flags, "resolved", resolved, ], - filePath + newFilePath ); } - return filePath; + return newFilePath; } async showDocumentSymbols(uri: string, @@ -424,7 +428,7 @@ export class LFortranCLIAccessor implements LFortranAccessor { const results: Record[] = JSON.parse(stdout); for (let i = 0, k = results.length; i < k; i++) { const result: Record = results[i]; - const symbolPath: string = + let symbolPath: string = this.resolve(result.filename, settings.compiler.flags); const location = result.location; @@ -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,