]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Use getbufoneline() in GetLineByteFromPos
authorMagnus Groß <magnus@mggross.com>
Fri, 2 Jun 2023 16:15:46 +0000 (18:15 +0200)
committerMagnus Groß <magnus@mggross.com>
Fri, 2 Jun 2023 16:15:46 +0000 (18:15 +0200)
This makes this more robust and also decreases the indentation level.

autoload/lsp/util.vim

index 2000ba233797d603fcda7b54ba89418dc80fa237..c9f24acd77e7d87cbe26b1f06f0501e3caf0bdc3 100644 (file)
@@ -168,12 +168,9 @@ export def GetLineByteFromPos(bnr: number, pos: dict<number>): number
       bnr->bufload()
     endif
 
-    var ltext: list<string> = 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