Skip to content

Commit d2cbe80

Browse files
authored
Fix cursor position calculation on complete done (#1008)
1 parent 1a7a6e0 commit d2cbe80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

autoload/lsp/ui/vim/completion.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ function! s:on_complete_done_after() abort
138138
" The VSCode always apply completion word as snippet.
139139
" It means we should place cursor to end of new inserted text as snippet does.
140140
let l:lines = lsp#utils#_split_by_eol(l:text)
141-
let l:end = l:range.end
142-
let l:end.line += len(l:lines) - 1
143-
let l:end.character = strchars(l:text[-1]) + (len(l:lines) > 1 ? 0 : l:end.character)
144-
call cursor(lsp#utils#position#lsp_to_vim('%', l:end))
141+
let l:start = l:range.start
142+
let l:start.line += len(l:lines) - 1
143+
let l:start.character += strchars(l:lines[-1])
144+
call cursor(lsp#utils#position#lsp_to_vim('%', l:start))
145145
endif
146146
endif
147147

0 commit comments

Comments
 (0)