|
15 | 15 | -- of the license. -- |
16 | 16 | ------------------------------------------------------------------------------ |
17 | 17 |
|
| 18 | +with Ada.Characters.Latin_1; |
18 | 19 | with Ada.Characters.Wide_Wide_Latin_1; |
19 | 20 | with Ada.Unchecked_Deallocation; |
20 | 21 |
|
@@ -144,6 +145,10 @@ package body LSP.Ada_Documents is |
144 | 145 |
|
145 | 146 | begin |
146 | 147 | if J.Has_Element then |
| 148 | + -- Update Line_Terminator of the document |
| 149 | + Self.Line_Terminator := Self.Text.Slice |
| 150 | + (J.Terminator_First_Marker, J.Terminator_Last_Marker); |
| 151 | + |
147 | 152 | loop |
148 | 153 | Self.Line_To_Marker.Append (J.First_Marker); |
149 | 154 | Last_Line_Terminated := J.Has_Line_Terminator; |
@@ -1143,6 +1148,20 @@ package body LSP.Ada_Documents is |
1143 | 1148 | end loop; |
1144 | 1149 | end Get_Symbols; |
1145 | 1150 |
|
| 1151 | + --------------------- |
| 1152 | + -- Line_Terminator -- |
| 1153 | + --------------------- |
| 1154 | + |
| 1155 | + function Line_Terminator (Self : Document'Class) return String is |
| 1156 | + begin |
| 1157 | + if Self.Line_Terminator.Is_Empty then |
| 1158 | + -- Document has no line terminator yet, return LF as most used |
| 1159 | + return (1 => Ada.Characters.Latin_1.LF); |
| 1160 | + else |
| 1161 | + return VSS.Strings.Conversions.To_UTF_8_String (Self.Line_Terminator); |
| 1162 | + end if; |
| 1163 | + end Line_Terminator; |
| 1164 | + |
1146 | 1165 | ----------------- |
1147 | 1166 | -- Get_Node_At -- |
1148 | 1167 | ----------------- |
@@ -1834,11 +1853,11 @@ package body LSP.Ada_Documents is |
1834 | 1853 |
|
1835 | 1854 | if not Doc_Text.Is_Empty then |
1836 | 1855 | Loc_Text.Append |
1837 | | - (VSS.Strings.Conversions.To_Virtual_String |
1838 | | - (ASCII.LF & ASCII.LF)); |
1839 | | - end if; |
| 1856 | + (VSS.Strings.To_Virtual_String |
| 1857 | + ((1 .. 2 => Ada.Characters.Wide_Wide_Latin_1.LF))); |
1840 | 1858 |
|
1841 | | - Loc_Text.Append (Doc_Text); |
| 1859 | + Loc_Text.Append (Doc_Text); |
| 1860 | + end if; |
1842 | 1861 |
|
1843 | 1862 | Item.documentation := |
1844 | 1863 | (Is_Set => True, |
|
0 commit comments