@@ -135,9 +135,13 @@ func (handler *InoHandler) transformClangdParams(method string, raw *json.RawMes
135
135
uri = p .TextDocument .URI
136
136
err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
137
137
case "textDocument/rangeFormatting" :
138
- // TODO
138
+ p := params .(* lsp.DocumentRangeFormattingParams )
139
+ uri = p .TextDocument .URI
140
+ err = handler .ino2cppDocumentRangeFormattingParams (p )
139
141
case "textDocument/onTypeFormatting" :
140
- // TODO
142
+ p := params .(* lsp.DocumentOnTypeFormattingParams )
143
+ uri = p .TextDocument .URI
144
+ err = handler .ino2cppDocumentOnTypeFormattingParams (p )
141
145
}
142
146
return
143
147
}
@@ -209,6 +213,13 @@ func (handler *InoHandler) deleteFileData(sourceURI lsp.DocumentURI) {
209
213
}
210
214
}
211
215
216
+ func (handler * InoHandler ) ino2cppTextDocumentIdentifier (doc * lsp.TextDocumentIdentifier ) error {
217
+ if data , ok := handler .data [doc .URI ]; ok {
218
+ doc .URI = data .targetURI
219
+ }
220
+ return nil
221
+ }
222
+
212
223
func (handler * InoHandler ) ino2cppTextDocumentItem (doc * lsp.TextDocumentItem ) error {
213
224
if strings .HasSuffix (string (doc .URI ), ".ino" ) {
214
225
data , targetBytes , err := handler .createFileData (doc .URI , doc .Text )
@@ -258,9 +269,19 @@ func (handler *InoHandler) ino2cppCodeActionParams(params *lsp.CodeActionParams)
258
269
return nil
259
270
}
260
271
261
- func (handler * InoHandler ) ino2cppTextDocumentIdentifier (doc * lsp.TextDocumentIdentifier ) error {
262
- if data , ok := handler .data [doc .URI ]; ok {
263
- doc .URI = data .targetURI
272
+ func (handler * InoHandler ) ino2cppDocumentRangeFormattingParams (params * lsp.DocumentRangeFormattingParams ) error {
273
+ handler .ino2cppTextDocumentIdentifier (& params .TextDocument )
274
+ if data , ok := handler .data [params .TextDocument .URI ]; ok {
275
+ params .Range .Start .Line = data .targetLineMap [params .Range .Start .Line ]
276
+ params .Range .End .Line = data .targetLineMap [params .Range .End .Line ]
277
+ }
278
+ return nil
279
+ }
280
+
281
+ func (handler * InoHandler ) ino2cppDocumentOnTypeFormattingParams (params * lsp.DocumentOnTypeFormattingParams ) error {
282
+ handler .ino2cppTextDocumentIdentifier (& params .TextDocument )
283
+ if data , ok := handler .data [params .TextDocument .URI ]; ok {
284
+ params .Position .Line = data .targetLineMap [params .Position .Line ]
264
285
}
265
286
return nil
266
287
}
0 commit comments