@@ -40,6 +40,8 @@ let insertTextFormatToInt f =
4040 match f with
4141 | Snippet -> 2
4242
43+ type textEdit = {range : range ; newText : string }
44+
4345type completionItem = {
4446 label : string ;
4547 kind : int ;
@@ -51,7 +53,7 @@ type completionItem = {
5153 insertText : string option ;
5254 documentation : markupContent option ;
5355 data : (string * string ) list option ;
54- range : range option ;
56+ additionalTextEdits : textEdit list option ;
5557}
5658
5759type location = {uri : string ; range : range }
@@ -62,8 +64,6 @@ type documentSymbolItem = {
6264 children : documentSymbolItem list ;
6365}
6466type renameFile = {oldUri : string ; newUri : string }
65- type textEdit = {range : range ; newText : string }
66-
6767type diagnostic = {range : range ; message : string ; severity : int }
6868
6969type optionalVersionedTextDocumentIdentifier = {
@@ -105,6 +105,14 @@ let stringifyRange r =
105105 (stringifyPosition r.start)
106106 (stringifyPosition r.end_)
107107
108+ let stringifyTextEdit (te : textEdit ) =
109+ Printf. sprintf
110+ {| {
111+ " range" : % s,
112+ " newText" : % s
113+ }| }
114+ (stringifyRange te.range) (wrapInQuotes te.newText)
115+
108116let stringifyMarkupContent (m : markupContent ) =
109117 Printf. sprintf {| {" kind" : % s, " value" : % s}| } (wrapInQuotes m.kind)
110118 (wrapInQuotes m.value)
@@ -143,10 +151,7 @@ let stringifyCompletionItem c =
143151 | Some doc -> stringifyMarkupContent doc) );
144152 (" sortText" , optWrapInQuotes c.sortText);
145153 (" filterText" , optWrapInQuotes c.filterText);
146- ( " insertText" ,
147- match c.range with
148- | Some _ -> None
149- | None -> optWrapInQuotes c.insertText );
154+ (" insertText" , optWrapInQuotes c.insertText);
150155 ( " insertTextFormat" ,
151156 match c.insertTextFormat with
152157 | None -> None
@@ -160,19 +165,10 @@ let stringifyCompletionItem c =
160165 (fields
161166 |> List. map (fun (key , value ) -> (key, Some (wrapInQuotes value)))
162167 |> stringifyObject ~indentation: 2 ) );
163- ( " textEdit" ,
164- match c.range with
165- | Some range ->
166- Some
167- (stringifyObject
168- [
169- (" range" , Some (stringifyRange range));
170- ( " newText" ,
171- optWrapInQuotes
172- (match c.insertText with
173- | None -> Some c.label
174- | v -> v) );
175- ])
168+ ( " additionalTextEdits" ,
169+ match c.additionalTextEdits with
170+ | Some additionalTextEdits ->
171+ Some (additionalTextEdits |> List. map stringifyTextEdit |> array )
176172 | None -> None );
177173 ]
178174
@@ -233,13 +229,6 @@ let stringifyRenameFile {oldUri; newUri} =
233229}| }
234230 (wrapInQuotes oldUri) (wrapInQuotes newUri)
235231
236- let stringifyTextEdit (te : textEdit ) =
237- Printf. sprintf {| {
238- " range" : % s,
239- " newText" : % s
240- }| }
241- (stringifyRange te.range) (wrapInQuotes te.newText)
242-
243232let stringifyoptionalVersionedTextDocumentIdentifier td =
244233 Printf. sprintf {| {
245234 " version" : % s,
0 commit comments