File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -122,15 +122,26 @@ function! s:on_complete_done_after() abort
122
122
\ ' character' : l: position [' character' ] + l: overflow_after ,
123
123
\ }
124
124
\ }
125
+
125
126
if get (l: completion_item , ' insertTextFormat' , 1 ) == 2
127
+ " insert Snippet.
126
128
call lsp#utils#text_edit#apply_text_edits (' %' , [{ ' range' : l: range , ' newText' : ' ' }])
127
129
if exists (' g:lsp_snippet_expand' ) && len (g: lsp_snippet_expand ) > 0
128
130
call g: lsp_snippet_expand [0 ]({ ' snippet' : l: text })
129
131
else
130
132
call s: simple_expand_text (l: text )
131
133
endif
132
134
else
135
+ " apply TextEdit.
133
136
call lsp#utils#text_edit#apply_text_edits (' %' , [{ ' range' : l: range , ' newText' : l: text }])
137
+
138
+ " The VSCode always apply completion word as snippet.
139
+ " It means we should place cursor to end of new inserted text as snippet does.
140
+ 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 ))
134
145
endif
135
146
endif
136
147
You can’t perform that action at this time.
0 commit comments