]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Don't use textEdit.newText, as textEdit.range isn't respected
authorAndreas Louv <andreas@louv.dk>
Thu, 9 Mar 2023 21:08:08 +0000 (22:08 +0100)
committerAndreas Louv <andreas@louv.dk>
Tue, 14 Mar 2023 15:18:12 +0000 (16:18 +0100)
autoload/lsp/completion.vim

index 03c29ab3efbc1c25ba573229110485d083789ab3..1e55bbadf56c1633db3499ad51fcc50409128f75 100644 (file)
@@ -88,9 +88,9 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
   var completeItems: list<dict<any>> = []
   for item in items
     var d: dict<any> = {}
-    if item->has_key('textEdit') && item.textEdit->has_key('newText')
-      d.word = item.textEdit.newText
-    elseif item->has_key('insertText')
+    # TODO: Add proper support for item.textEdit.newText and item.textEdit.range
+    # Keep in mind that item.textEdit.range can start be way before the typed keyword.
+    if item->has_key('insertText')
       d.word = item.insertText
     else
       d.word = item.label
@@ -149,19 +149,6 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
 
     var start_col: number = 0
 
-    # FIXME: The following doesn't work with typescript as one of the
-    # completion item has a start column that is before the special character.
-    # For example, when completing the methods for "str.", the dot is removed.
-    #
-    # # Find the start column for the completion.  If any of the entries
-    # # returned by the LSP server has a starting position, then use that.
-    # for item in items
-    #   if item->has_key('textEdit')
-    #     start_col = item.textEdit.range.start.character + 1
-    #     break
-    #   endif
-    # endfor
-
     # LSP server didn't return a starting position for completion, search
     # backwards from the current cursor position for a non-keyword character.
     if start_col == 0