]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Send charcol when requesting code action
authorAndreas Louv <andreas@louv.dk>
Sun, 12 Mar 2023 22:41:09 +0000 (23:41 +0100)
committerAndreas Louv <andreas@louv.dk>
Mon, 13 Mar 2023 23:35:23 +0000 (00:35 +0100)
The typescript-language-server will provide better code actions when
knowing which column you stand on. For instance the "add missing import"
action works more reliable when the server knows the current column.

autoload/lsp/lspserver.vim

index f0397c8dfd90321090bfdf35e9ebb855388df9fa..81bb8c1b7a48945b7c82da4598ce004e6df6454c 100644 (file)
@@ -1342,8 +1342,15 @@ def CodeAction(lspserver: dict<any>, fname_arg: string, line1: number,
   var fname: string = fname_arg->fnamemodify(':p')
   var bnr: number = fname_arg->bufnr()
   var r: dict<dict<number>> = {
-                 start: {line: line1 - 1, character: 0},
-                 end: {line: line2 - 1, character: charcol([line2, '$']) - 1}}
+    start: {
+      line: line1 - 1,
+      character: line1 == line2 ? charcol('.') - 1 : 0
+    },
+    end: {
+      line: line2 - 1,
+      character: charcol([line2, '$']) - 1
+    }
+  }
   params->extend({textDocument: {uri: util.LspFileToUri(fname)}, range: r})
   var d: list<dict<any>> = []
   for lnum in range(line1, line2)