You've already forked ada_language_server
mirror of
https://github.com/AdaCore/ada_language_server.git
synced 2026-02-12 12:45:50 -08:00
Rewrite To_LSP_Column to compute LSP column index at the end
This commit is contained in:
@@ -22,8 +22,7 @@ package body LSP.Text_Documents.Langkit_Documents is
|
||||
|
||||
function To_LSP_Column
|
||||
(Line_Text : VSS.Strings.Virtual_String;
|
||||
Column : Langkit_Support.Slocs.Column_Number;
|
||||
At_Start : Boolean := True) return Natural;
|
||||
Column : Langkit_Support.Slocs.Column_Number) return Natural;
|
||||
|
||||
use type Langkit_Support.Slocs.Line_Number;
|
||||
|
||||
@@ -87,7 +86,7 @@ package body LSP.Text_Documents.Langkit_Documents is
|
||||
an_end =>
|
||||
(line => To_LSP_Line (A_Range.End_Line),
|
||||
character => To_LSP_Column
|
||||
(Self.Line (A_Range.End_Line), A_Range.End_Column, False)));
|
||||
(Self.Line (A_Range.End_Line), A_Range.End_Column)));
|
||||
|
||||
function To_A_Range
|
||||
(Start_Line_Text : VSS.Strings.Virtual_String;
|
||||
@@ -101,7 +100,7 @@ package body LSP.Text_Documents.Langkit_Documents is
|
||||
an_end =>
|
||||
(line => To_LSP_Line (A_Range.End_Line),
|
||||
character => To_LSP_Column
|
||||
(End_Line_Text, A_Range.End_Column, False)));
|
||||
(End_Line_Text, A_Range.End_Column)));
|
||||
|
||||
---------------------
|
||||
-- To_LSP_Position --
|
||||
@@ -112,9 +111,8 @@ package body LSP.Text_Documents.Langkit_Documents is
|
||||
Sloc : Langkit_Support.Slocs.Source_Location)
|
||||
return LSP.Structures.Position
|
||||
is
|
||||
(line => To_LSP_Line (Sloc.Line),
|
||||
character => To_LSP_Column
|
||||
(Self.Line (Sloc.Line), Sloc.Column, False));
|
||||
(line => To_LSP_Line (Sloc.Line),
|
||||
character => To_LSP_Column (Self.Line (Sloc.Line), Sloc.Column));
|
||||
|
||||
-------------------
|
||||
-- To_LSP_Column --
|
||||
@@ -122,26 +120,21 @@ package body LSP.Text_Documents.Langkit_Documents is
|
||||
|
||||
function To_LSP_Column
|
||||
(Line_Text : VSS.Strings.Virtual_String;
|
||||
Column : Langkit_Support.Slocs.Column_Number;
|
||||
At_Start : Boolean := True) return Natural
|
||||
Column : Langkit_Support.Slocs.Column_Number) return Natural
|
||||
is
|
||||
Iterator : VSS.Strings.Character_Iterators.Character_Iterator :=
|
||||
Line_Text.At_First_Character;
|
||||
Success : Boolean with Unreferenced;
|
||||
begin
|
||||
-- Iterating forward through the line, initial
|
||||
-- iterator points to the first characters, thus "starts" from the
|
||||
-- second one.
|
||||
-- Iterating forward through the line, initial iterator points to the
|
||||
-- first characters, thus "starts" from the second one (to improve
|
||||
-- performance).
|
||||
|
||||
for J in 2 .. Column loop
|
||||
Success := Iterator.Forward;
|
||||
end loop;
|
||||
|
||||
if At_Start then
|
||||
return Natural (Iterator.First_UTF16_Offset);
|
||||
else
|
||||
return Natural (Iterator.Last_UTF16_Offset);
|
||||
end if;
|
||||
return Natural (Iterator.First_UTF16_Offset);
|
||||
end To_LSP_Column;
|
||||
|
||||
----------------------
|
||||
|
||||
Reference in New Issue
Block a user