# Highlight the selected symbol
var col: number =
- bnr->getbufoneline(symbolTable[mid].outlineLine)->match('\S') + 1
+ util.GetBufOneLine(bnr, symbolTable[mid].outlineLine)->match('\S') + 1
prop_add(symbolTable[mid].outlineLine, col,
{bufnr: bnr, type: 'LspOutlineHighlight',
length: symbolTable[mid].name->len()})
endif
var lnum = range.start.line + 1
- var text: string = bnr->getbufoneline(lnum)
+ var text: string = util.GetBufOneLine(bnr, lnum)
menuItems->add($'{lnum}: {text}')
endfor
if !bnr->bufloaded()
bnr->bufload()
endif
- var text: string = bnr->getbufoneline(range.start.line + 1)->trim("\t ", 1)
+ var text: string = util.GetBufOneLine(bnr, range.start.line + 1)->trim("\t ", 1)
qflist->add({filename: fname,
lnum: range.start.line + 1,
col: util.GetLineByteFromPos(bnr, range.start) + 1,
# lines.
var dellastline: bool = false
if start_line == 0 && bnr->getbufinfo()[0].linecount == 1 &&
- bnr->getbufoneline(1) == ''
+ util.GetBufOneLine(bnr, 1) == ''
dellastline = true
endif
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
+ return bnr->getbufline(lnum)[0]
+ endif
+enddef
+
# vim: tabstop=8 shiftwidth=2 softtabstop=2
assert_equal([1, 5], [line('.'), col('.')])
var ids = popup_list()
assert_equal(1, ids->len())
- assert_match('Incompatible pointer to integer', getbufoneline(ids[0]->winbufnr(), 1, '$'))
+ assert_match('Incompatible pointer to integer', getbufoneline(ids[0]->winbufnr(), 1))
popup_clear()
cursor(1, 6)
:LspDiagHere
assert_equal([1, 9], [line('.'), col('.')])
ids = popup_list()
assert_equal(1, ids->len())
- assert_match('Initializer element is not', getbufoneline(ids[0]->winbufnr(), 1, '$'))
+ assert_match('Initializer element is not', getbufoneline(ids[0]->winbufnr(), 1))
popup_clear()
# Line without diagnostics