mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(tohtml): extmark text may be out of bounds
This commit is contained in:
parent
598fd77d95
commit
25db0a1385
@ -519,9 +519,12 @@ local function _styletable_extmarks_virt_text(state, extmark, namespaces)
|
|||||||
--- @type integer,integer
|
--- @type integer,integer
|
||||||
local row, col = extmark[2], extmark[3]
|
local row, col = extmark[2], extmark[3]
|
||||||
if
|
if
|
||||||
extmark[4].virt_text_pos == 'inline'
|
row < state.buflen
|
||||||
or extmark[4].virt_text_pos == 'eol'
|
and (
|
||||||
or extmark[4].virt_text_pos == 'overlay'
|
extmark[4].virt_text_pos == 'inline'
|
||||||
|
or extmark[4].virt_text_pos == 'eol'
|
||||||
|
or extmark[4].virt_text_pos == 'overlay'
|
||||||
|
)
|
||||||
then
|
then
|
||||||
if extmark[4].virt_text_pos == 'eol' then
|
if extmark[4].virt_text_pos == 'eol' then
|
||||||
style_line_insert_virt_text(styletable[row + 1], #vim.fn.getline(row + 1) + 1, { ' ' })
|
style_line_insert_virt_text(styletable[row + 1], #vim.fn.getline(row + 1) + 1, { ' ' })
|
||||||
@ -1144,7 +1147,13 @@ local function extend_pre(out, state)
|
|||||||
local line = vim.api.nvim_buf_get_lines(state.bufnr, row - 1, row, false)[1] or ''
|
local line = vim.api.nvim_buf_get_lines(state.bufnr, row - 1, row, false)[1] or ''
|
||||||
local s = ''
|
local s = ''
|
||||||
s = s .. _pre_text_to_html(state, row)
|
s = s .. _pre_text_to_html(state, row)
|
||||||
for col = 1, #line + 1 do
|
local true_line_len = #line + 1
|
||||||
|
for k in pairs(style_line) do
|
||||||
|
if type(k) == 'number' and k > true_line_len then
|
||||||
|
true_line_len = k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for col = 1, true_line_len do
|
||||||
local cell = style_line[col]
|
local cell = style_line[col]
|
||||||
--- @type table?
|
--- @type table?
|
||||||
local char
|
local char
|
||||||
@ -1191,7 +1200,7 @@ local function extend_pre(out, state)
|
|||||||
char = cell[4][#cell[4]]
|
char = cell[4][#cell[4]]
|
||||||
end
|
end
|
||||||
|
|
||||||
if col == #line + 1 and not char then
|
if col == true_line_len and not char then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user