]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: starttext maybe incorrect
authorshane.xb.qian <shane.qian@foxmail.com>
Wed, 22 Mar 2023 06:21:44 +0000 (14:21 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Wed, 22 Mar 2023 06:21:44 +0000 (14:21 +0800)
// set a safeguard of chcol

Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
autoload/lsp/completion.vim

index 65ad42bfdad7eb50819007858fb718693e06e574..4352591eeea68655f5248d2ae9abd12e3885d3b3 100644 (file)
@@ -90,7 +90,7 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
 
   # Get the keyword prefix before the current cursor column.
   var chcol = charcol('.')
-  var starttext = getline('.')[ : chcol - 2]
+  var starttext = chcol == 1 ? '' : getline('.')[ : chcol - 2]
   var [prefix, start_idx, end_idx] = starttext->tolower()->matchstrpos('\k*$')
   var start_col = start_idx + 1