Skip to content

Commit a06806a

Browse files
VA28-021: Activate snippet formatting by default
Also set filterText to prevent clients for hiding snippet (VS code for example).
1 parent 95a945d commit a06806a

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

source/ada/lsp-ada_completions.adb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ package body LSP.Ada_Completions is
4949

5050
Me_Formatting : constant GNATCOLL.Traces.Trace_Handle :=
5151
GNATCOLL.Traces.Create
52-
("ALS.COMPLETION.FORMATTING", Default => GNATCOLL.Traces.Off);
52+
("ALS.COMPLETION.FORMATTING", Default => GNATCOLL.Traces.On);
5353

5454
------------------------
5555
-- Is_Full_Sloc_Equal --
@@ -422,6 +422,14 @@ package body LSP.Ada_Completions is
422422
Result.insertTextMode :=
423423
(Is_Set => True,
424424
Value => asIs);
425+
426+
-- Label is too verbose and can conflict with client filtering
427+
-- set filterText to the content of the span we are replacing.
428+
Result.filterText :=
429+
(Is_Set => True,
430+
Value =>
431+
VSS.Strings.Conversions.To_Virtual_String (Prefix));
432+
425433
Result.textEdit :=
426434
(Is_Set => True,
427435
Value =>

testsuite/ada_lsp/completion.snippet.formatting/test.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"label": "Params of Bar",
146146
"kind": 15,
147147
"sortText": "+00",
148+
"filterText": "Bar (",
148149
"insertText": "${1:A : Integer}, ${2:B : Integer})$0",
149150
"insertTextFormat": 2,
150151
"textEdit": {
@@ -195,6 +196,7 @@
195196
"label": "Params of Bar",
196197
"kind": 15,
197198
"sortText": "+03",
199+
"filterText": "Bar (",
198200
"insertText": "AAAAAAAA => ${1:Integer}, BB => ${2:Integer}, CCCCCCCC => ${3:Integer}, DDDDDDDDDDDD => ${4:Integer}, E => ${5:Integer})$0",
199201
"insertTextFormat": 2,
200202
"textEdit": {
@@ -269,6 +271,7 @@
269271
"label": "Params of Bar",
270272
"kind": 15,
271273
"sortText": "+09",
274+
"filterText": "Bar (",
272275
"insertText": "A => ${1:Integer}, B => ${2:Integer}, C => ${3:Integer}, D => ${4:Integer}, E => ${5:Integer}, F => ${6:Integer}, G => ${7:Integer}, H => ${8:Integer}, I => ${9:Integer}, J => ${10:Integer})$0",
273276
"insertTextFormat": 2,
274277
"textEdit": {

testsuite/ada_lsp/completion.snippet.formatting2/test.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"label": "Params of Bar",
157157
"kind": 15,
158158
"sortText": "+0",
159+
"filterText": "Bar (",
159160
"insertText": "A => ${1:Integer}, BBBBB => ${2:Integer}, CCCCCCC => ${3:Integer}, DDD => ${4:Float})$0",
160161
"insertTextFormat": 2,
161162
"textEdit": {
@@ -343,6 +344,7 @@
343344
"label": "Params of Bar",
344345
"kind": 15,
345346
"sortText": "+0",
347+
"filterText": "Bar (A => 1,",
346348
"insertText": " BBBBB => ${2:Integer}, CCCCCCC => ${3:Integer}, DDD => ${4:Float})$0",
347349
"insertTextFormat": 2,
348350
"textEdit": {

testsuite/ada_lsp/completion.snippet.formatting3/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"label": "Params of Foo_Bar",
157157
"kind": 15,
158158
"sortText": "+0",
159+
"filterText": "Foo_Bar (",
159160
"insertText": "A => ${1:A : Integer;}, BBBBBB => ${2:BBBBBB : Float;}, CCCC => ${3:CCCC : String;}, Bar => ${4:with procedure Bar (X : Integer);})$0",
160161
"insertTextFormat": 2,
161162
"insertTextMode": 1,

0 commit comments

Comments
 (0)