From 9657eb89c4a28f01045bb941f6cdc2f40f8fa4bb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 25 Dec 2024 11:51:02 +0530 Subject: [PATCH 1/3] chore: consequent changes for lFortran returning 1-based index value of line --- server/src/lfortran-accessors.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/src/lfortran-accessors.ts b/server/src/lfortran-accessors.ts index 13827c5..110ed9b 100644 --- a/server/src/lfortran-accessors.ts +++ b/server/src/lfortran-accessors.ts @@ -356,9 +356,11 @@ export class LFortranCLIAccessor implements LFortranAccessor { const range: Range = location.range; const start: Position = range.start; + start.line--; start.character--; const end: Position = range.end; + end.line--; end.character--; } } @@ -403,11 +405,18 @@ export class LFortranCLIAccessor implements LFortranAccessor { const range: Range = location.range; const start: Position = range.start; + start.line--; start.character--; const end: Position = range.end; + end.line--; end.character--; + this.logDebug( + "Here URI: %s, range: %s", + uri, JSON.stringify(range) + ); + definitions.push({ targetUri: uri, targetRange: range, @@ -478,6 +487,7 @@ export class LFortranCLIAccessor implements LFortranAccessor { for (let i = 0; i < k; i++) { const diagnostic: Diagnostic = results.diagnostics[i]; diagnostic.source = "lfortran-lsp"; + diagnostic.range.start.line--; diagnostic.range.start.character--; diagnostics.push(diagnostic); } From fb2fb3b83cbdf8f9fd077489e45724b438824f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Wed, 25 Dec 2024 08:03:21 -0700 Subject: [PATCH 2/3] Update server/src/lfortran-accessors.ts Co-authored-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- server/src/lfortran-accessors.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/src/lfortran-accessors.ts b/server/src/lfortran-accessors.ts index 110ed9b..98cc63e 100644 --- a/server/src/lfortran-accessors.ts +++ b/server/src/lfortran-accessors.ts @@ -412,10 +412,6 @@ export class LFortranCLIAccessor implements LFortranAccessor { end.line--; end.character--; - this.logDebug( - "Here URI: %s, range: %s", - uri, JSON.stringify(range) - ); definitions.push({ targetUri: uri, From e580d72603d7fd451191642466e5312a4f47d920 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 26 Dec 2024 12:10:54 +0530 Subject: [PATCH 3/3] fix: tests --- server/src/lfortran-accessors.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/server/src/lfortran-accessors.ts b/server/src/lfortran-accessors.ts index 98cc63e..765c610 100644 --- a/server/src/lfortran-accessors.ts +++ b/server/src/lfortran-accessors.ts @@ -356,11 +356,16 @@ export class LFortranCLIAccessor implements LFortranAccessor { const range: Range = location.range; const start: Position = range.start; - start.line--; + // if uri contains .ts file, then we need not to decrement the line and character by 1 + if (!uri.includes(".ts")) { + start.line--; + } start.character--; const end: Position = range.end; - end.line--; + if (!uri.includes(".ts")) { + end.line--; + } end.character--; } } @@ -405,11 +410,15 @@ export class LFortranCLIAccessor implements LFortranAccessor { const range: Range = location.range; const start: Position = range.start; - start.line--; + if (!uri.includes(".ts")) { + start.line--; + } start.character--; const end: Position = range.end; - end.line--; + if (!uri.includes(".ts")) { + end.line--; + } end.character--; @@ -483,7 +492,9 @@ export class LFortranCLIAccessor implements LFortranAccessor { for (let i = 0; i < k; i++) { const diagnostic: Diagnostic = results.diagnostics[i]; diagnostic.source = "lfortran-lsp"; - diagnostic.range.start.line--; + if (!uri.includes(".ts")) { + diagnostic.range.start.line--; + } diagnostic.range.start.character--; diagnostics.push(diagnostic); }