From: Girish Palya Date: Wed, 19 Jul 2023 13:21:07 +0000 (+0200) Subject: Optimize regex comparison in omnifunc X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ccae1e8ad123117ac9dffeabd8bc7d122ab0d808;p=vim-lsp.git Optimize regex comparison in omnifunc M autoload/lsp/completion.vim --- diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 70bb2ae..37690a0 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -441,15 +441,10 @@ def g:LspOmniFunc(findstart: number, base: string): any lspserver.getCompletion(1, '') # locate the start of the word - var line = getline('.') - var start = charcol('.') - 1 - var keyword: string = '' - while start > 0 && line[start - 1] =~ '\k' - keyword = line[start - 1] .. keyword - start -= 1 - endwhile + var line = getline('.')->strpart(0, col('.') - 1) + var keyword = line->matchstr('\k\+$') lspserver.omniCompleteKeyword = keyword - return line->byteidx(start) + return line->len() - keyword->len() else # Wait for the list of matches from the LSP server var count: number = 0