Skip to content

Commit 0eff844

Browse files
MaxDillonokuuva
authored andcommitted
fix(table): remove unnecessary line height check
1 parent 0eb76e3 commit 0eff844

1 file changed

Lines changed: 27 additions & 35 deletions

File tree

lua/render-markdown/render/markdown/table.lua

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -653,56 +653,48 @@ function Render:row_wrapped(row, row_index)
653653
})
654654

655655
-- Lines 1..height-1: overlay buffer wrap continuations, then virt_lines.
656-
if height > 1 then
657-
local virt_lines = {} ---@type render.md.mark.Line[]
658-
for vl = 1, height - 1 do
659-
if vl < buf_screen_lines then
660-
local byte_col = vim.fn.byteidx(buf_line, vl * win_width)
661-
if byte_col < 0 then
662-
byte_col = #buf_line
663-
end
664-
if #virt_lines > 0 then
665-
self.marks:add(
666-
self.config,
667-
'virtual_lines',
668-
row.node.start_row,
669-
0,
670-
{
671-
virt_lines = virt_lines,
672-
virt_lines_above = false,
673-
}
674-
)
675-
virt_lines = {}
676-
end
656+
local virt_lines = {} ---@type render.md.mark.Line[]
657+
for vl = 1, height - 1 do
658+
if vl < buf_screen_lines then
659+
local byte_col = vim.fn.byteidx(buf_line, vl * win_width)
660+
if byte_col < 0 then
661+
byte_col = #buf_line
662+
end
663+
if #virt_lines > 0 then
677664
self.marks:add(
678665
self.config,
679-
'table_border',
666+
'virtual_lines',
680667
row.node.start_row,
681-
byte_col,
668+
0,
682669
{
683-
virt_text = build_line(vl):get(),
684-
virt_text_pos = 'overlay',
685-
hl_mode = 'combine',
670+
virt_lines = virt_lines,
671+
virt_lines_above = false,
686672
}
687673
)
688-
else
689-
local vline = self:indent():line(true):extend(build_line(vl))
690-
virt_lines[#virt_lines + 1] = vline:get()
674+
virt_lines = {}
691675
end
692-
end
693-
if #virt_lines > 0 then
694676
self.marks:add(
695677
self.config,
696-
'virtual_lines',
678+
'table_border',
697679
row.node.start_row,
698-
0,
680+
byte_col,
699681
{
700-
virt_lines = virt_lines,
701-
virt_lines_above = false,
682+
virt_text = build_line(vl):get(),
683+
virt_text_pos = 'overlay',
684+
hl_mode = 'combine',
702685
}
703686
)
687+
else
688+
local vline = self:indent():line(true):extend(build_line(vl))
689+
virt_lines[#virt_lines + 1] = vline:get()
704690
end
705691
end
692+
if #virt_lines > 0 then
693+
self.marks:add(self.config, 'virtual_lines', row.node.start_row, 0, {
694+
virt_lines = virt_lines,
695+
virt_lines_above = false,
696+
})
697+
end
706698
end
707699

708700
---Use low priority to include pipe marks

0 commit comments

Comments
 (0)