Skip to content

Commit b429c12

Browse files
MaxDillonokuuva
authored andcommitted
feat(table): replace nvim_buf_get_lines with node:line
1 parent e8ad5bd commit b429c12

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,10 @@ function Render:compute_layout()
254254
end
255255
end
256256
-- Raw buffer line screen-wrap: ceil(display_width_of_source / win_width)
257-
local buf_line = vim.api.nvim_buf_get_lines(
258-
self.context.buf,
259-
row.node.start_row,
260-
row.node.start_row + 1,
261-
false
262-
)[1] or ''
257+
local _, line = row.node:line('first', 0)
258+
line = line or ''
263259
local raw_screen_lines =
264-
math.max(1, math.ceil(str.width(buf_line) / win_width))
260+
math.max(1, math.ceil(str.width(line) / win_width))
265261
if raw_screen_lines > max_lines then
266262
max_lines = raw_screen_lines
267263
needs_wrap = true
@@ -619,12 +615,8 @@ function Render:row_wrapped(row, row_index)
619615
return line
620616
end
621617

622-
local buf_line = vim.api.nvim_buf_get_lines(
623-
self.context.buf,
624-
row.node.start_row,
625-
row.node.start_row + 1,
626-
false
627-
)[1] or ''
618+
local _, buf_line = row.node:line('first', 0)
619+
buf_line = buf_line or ''
628620
local win_width = env.win.width(self.context.win)
629621
local buf_screen_lines =
630622
math.max(1, math.ceil(str.width(buf_line) / win_width))

0 commit comments

Comments
 (0)