From: Magnus Groß Date: Fri, 2 Jun 2023 16:15:46 +0000 (+0200) Subject: Use getbufoneline() in GetLineByteFromPos X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ff89d0d1256d1d729736aa5d4433eb7471c35fd0;p=vim-lsp.git Use getbufoneline() in GetLineByteFromPos This makes this more robust and also decreases the indentation level. --- diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 2000ba2..c9f24ac 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -168,12 +168,9 @@ export def GetLineByteFromPos(bnr: number, pos: dict): number bnr->bufload() endif - var ltext: list = bnr->getbufline(pos.line + 1) - if !ltext->empty() - var bidx = ltext[0]->byteidx(col) - if bidx != -1 - return bidx - endif + var bidx = GetBufOneLine(bnr, pos.line + 1)->byteidx(col) + if bidx != -1 + return bidx endif endif