From ff89d0d1256d1d729736aa5d4433eb7471c35fd0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Magnus=20Gro=C3=9F?= Date: Fri, 2 Jun 2023 18:15:46 +0200 Subject: [PATCH] Use getbufoneline() in GetLineByteFromPos This makes this more robust and also decreases the indentation level. --- autoload/lsp/util.vim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 -- 2.48.1