@@ -107,11 +107,7 @@ function! s:on_complete_done_after() abort
107
107
else
108
108
let l: overflow_before = 0
109
109
let l: overflow_after = 0
110
- let l: text = get (l: completion_item , ' insertText' , ' ' )
111
- if empty (l: text )
112
- " When insertText is `falsy` the label is used as the insert text
113
- let l: text = get (l: completion_item , ' label' , l: completed_item [' word' ])
114
- endif
110
+ let l: text = s: get_completion_text (l: completion_item )
115
111
endif
116
112
117
113
" apply snipept or text_edit
@@ -171,11 +167,7 @@ function! s:is_expandable(done_line, done_position, complete_position, completio
171
167
let l: text_edit_after = strcharpart (l: completed_line , a: completion_item [' textEdit' ][' range' ][' end' ][' character' ], strchars (l: completed_line ) - a: completion_item [' textEdit' ][' range' ][' end' ][' character' ])
172
168
return a: done_line !=# l: text_edit_before . s: trim_unmeaning_tabstop (a: completion_item [' textEdit' ][' newText' ]) . l: text_edit_after
173
169
endif
174
- let l: text = get (a: completion_item , ' insertText' , ' ' )
175
- if empty (l: text )
176
- let l: text = get (a: completion_item , ' label' , a: completed_item [' word' ])
177
- endif
178
- return l: text !=# s: trim_unmeaning_tabstop (a: completed_item [' word' ])
170
+ return s: get_completion_text (a: completed_item ) !=# s: trim_unmeaning_tabstop (a: completed_item [' word' ])
179
171
endfunction
180
172
181
173
"
@@ -280,6 +272,18 @@ function! s:simple_expand_text(text) abort
280
272
call cursor (l: pos )
281
273
endfunction
282
274
275
+ "
276
+ " Get completion text from CompletionItem. Fallback to label when insertText
277
+ " is falsy
278
+ "
279
+ function ! s: get_completion_text (item) abort
280
+ let l: text = get (a: item , ' insertText' , ' ' )
281
+ if empty (l: text )
282
+ let l: text = get (a: item , ' label' , a: item [' word' ])
283
+ endif
284
+ return l: text
285
+ endfunction
286
+
283
287
"
284
288
" Get script id that uses to call `s:` function in feedkeys.
285
289
"
0 commit comments