Skip to content

Commit 3e53d1a

Browse files
committed
Improve snippet completion parsing
Previously the expanded content was found using a rough regex which had several problems. Instead, simply remember the column that the completion request starts from, and take the completed string between the start point and the cursor.
1 parent aec2068 commit 3e53d1a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

autoload/OmniSharp/actions/complete.vim

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ function! OmniSharp#actions#complete#ExpandSnippet() abort
4141
return
4242
endif
4343

44-
let line = strpart(getline('.'), 0, col('.')-1)
45-
let remove_whitespace_regex = '^\s*\(.\{-}\)\s*$'
46-
47-
let completion = matchstr(line, '.*\zs\s\W.\+(.*)')
48-
let completion = substitute(completion, remove_whitespace_regex, '\1', '')
44+
let completion = strpart(getline('.'), s:last_startcol, col('.') - 1)
4945

5046
let should_expand_completion = len(completion) != 0
5147

@@ -74,6 +70,7 @@ function! s:StdioGetCompletions(partial, Callback) abort
7470
let wantDoc = wantDocPopup ? 'false'
7571
\ : g:omnicomplete_fetch_full_documentation ? 'true' : 'false'
7672
let wantSnippet = g:OmniSharp_want_snippet ? 'true' : 'false'
73+
let s:last_startcol = col('.') - len(a:partial) - 1
7774
let parameters = {
7875
\ 'WordToComplete': a:partial,
7976
\ 'WantDocumentationForEveryCompletionResult': wantDoc,

0 commit comments

Comments
 (0)