]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: util.GetBufOneLine is a bit useless
authorshane.xb.qian <shane.qian@foxmail.com>
Tue, 6 Jun 2023 03:59:20 +0000 (11:59 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Tue, 6 Jun 2023 03:59:20 +0000 (11:59 +0800)
autoload/lsp/outline.vim
autoload/lsp/symbol.vim
autoload/lsp/textedit.vim
autoload/lsp/util.vim

index ad0cc36c023e1e550e2b1e63826929a53196be96..2979d2096427114a882b0e2509223b76b9c60df2 100644 (file)
@@ -194,7 +194,7 @@ def OutlineHighlightCurrentSymbol()
 
   # Highlight the selected symbol
   var col: number =
-    util.GetBufOneLine(bnr, symbolTable[mid].outlineLine)->match('\S') + 1
+    bnr->getbufline(symbolTable[mid].outlineLine)->get(0, '')->match('\S') + 1
   prop_add(symbolTable[mid].outlineLine, col,
                        {bufnr: bnr, type: 'LspOutlineHighlight',
                        length: symbolTable[mid].name->len()})
index 136d99a973b7db96a3d2ad5ee47800f661c23c95..5914f92a419bb28112e7efd4be50a321792fd9e1 100644 (file)
@@ -349,7 +349,7 @@ def PeekLocations(lspserver: dict<any>, locations: list<dict<any>>,
     bnr->bufload()
 
     var lnum = range.start.line + 1
-    var text: string = util.GetBufOneLine(bnr, lnum)
+    var text: string = bnr->getbufline(lnum)->get(0, '')
     menuItems->add($'{lnum}: {text}')
   endfor
 
@@ -389,7 +389,7 @@ export def ShowLocations(lspserver: dict<any>, locations: list<dict<any>>,
       bnr = fname->bufadd()
     endif
     bnr->bufload()
-    var text: string = util.GetBufOneLine(bnr, range.start.line + 1)->trim("\t ", 1)
+    var text: string = bnr->getbufline(range.start.line + 1)->get(0, '')->trim("\t ", 1)
     qflist->add({filename: fname,
                        lnum: range.start.line + 1,
                        col: util.GetLineByteFromPos(bnr, range.start) + 1,
index 374d9075c6c5edf995e520ac37b66878d7064bcd..00c01727bf39ed3015fbd3600547c5798bf5a689 100644 (file)
@@ -171,7 +171,7 @@ export def ApplyTextEdits(bnr: number, text_edits: list<dict<any>>): void
   # lines.
   var dellastline: bool = false
   if start_line == 0 && bnr->getbufinfo()[0].linecount == 1 &&
-                                       util.GetBufOneLine(bnr, 1)->empty()
+                                       bnr->getbufline(1)->get(0, '')->empty()
     dellastline = true
   endif
 
index 220d14cb60630f3c7d82f479af7db186c9b01489..708e8b86edc049458e8e6c27ca42cee0e4751a9a 100644 (file)
@@ -169,7 +169,7 @@ export def GetLineByteFromPos(bnr: number, pos: dict<number>): number
   # Need a loaded buffer to read the line and compute the offset
   bnr->bufload()
 
-  var ltext: string = GetBufOneLine(bnr, pos.line + 1)
+  var ltext: string = bnr->getbufline(pos.line + 1)->get(0, '')
   if ltext->empty()
     return col
   endif
@@ -196,7 +196,7 @@ export def GetCharIdxWithoutCompChar(bnr: number, pos: dict<number>): number
   # Need a loaded buffer to read the line and compute the offset
   bnr->bufload()
 
-  var ltext: string = GetBufOneLine(bnr, pos.line + 1)
+  var ltext: string = bnr->getbufline(pos.line + 1)->get(0, '')
   if ltext->empty()
     return col
   endif
@@ -353,17 +353,4 @@ export def FindNearestRootDir(startDir: string, files: list<any>): string
   return sortedList[0]
 enddef
 
-export def GetBufOneLine(bnr: number, lnum: number): string
-  if exists_compiled('*getbufoneline')
-    # getbufoneline() was introduced in patch 9.0.0916
-    return bnr->getbufoneline(lnum)
-  else
-    var l = bnr->getbufline(lnum)
-    if l->empty()
-      return ''
-    endif
-    return l[0]
-  endif
-enddef
-
 # vim: tabstop=8 shiftwidth=2 softtabstop=2