Skip to content

Commit 9ab4ea7

Browse files
committed
feat(table): replace nvim_buf_get_lines with node:line
1 parent 0e79080 commit 9ab4ea7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,8 @@ function Render:compute_layout()
241241
end
242242
end
243243
-- Raw buffer line screen-wrap: ceil(display_width_of_source / win_width)
244-
local buf_line = vim.api.nvim_buf_get_lines(
245-
self.context.buf, row.node.start_row, row.node.start_row + 1, false
246-
)[1] or ''
247-
local raw_screen_lines = math.max(1, math.ceil(str.width(buf_line) / win_width))
244+
local _, line = row.node:line('first', 0)
245+
local raw_screen_lines = math.ceil(str.width(line) / win_width)
248246
if raw_screen_lines > max_lines then
249247
max_lines = raw_screen_lines
250248
needs_wrap = true
@@ -582,11 +580,9 @@ function Render:row_wrapped(row, row_index)
582580
return line
583581
end
584582

585-
local buf_line = vim.api.nvim_buf_get_lines(
586-
self.context.buf, row.node.start_row, row.node.start_row + 1, false
587-
)[1] or ''
588583
local win_width = env.win.width(self.context.win)
589-
local buf_screen_lines = math.max(1, math.ceil(str.width(buf_line) / win_width))
584+
local _, buf_line = row.node:line('first', 0) or ''
585+
local buf_screen_lines = math.ceil(str.width(buf_line) / win_width)
590586

591587
-- Line 0: conceal the source line then overlay the rendered row on top.
592588
if #buf_line > 0 then

0 commit comments

Comments
 (0)