Skip to content

Commit 01f4718

Browse files
committed
fix(table): class name collision
`render.md.table.Layout` was already introduced to `main`. Renamed the new `Layout` into `WrapLayout`.
1 parent 1af7c14 commit 01f4718

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ local Alignment = {
4848
---@field pipes render.md.Node[]
4949
---@field cells render.md.Node[]
5050

51-
---@class render.md.table.Layout
52-
---@field wrap boolean
51+
---@class render.md.table.WrapLayout
52+
---@field enabled boolean
5353
---@field col_widths integer[]
5454
---@field row_heights integer[]
5555

5656
---@class render.md.render.Table: render.md.Render
5757
---@field private config render.md.table.Config
5858
---@field private data render.md.table.Data
59-
---@field private layout render.md.table.Layout
59+
---@field private wrap_layout render.md.table.WrapLayout
6060
local Render = setmetatable({}, Base)
6161
Render.__index = Render
6262

@@ -132,12 +132,12 @@ function Render:setup()
132132
end
133133

134134
self.data = { layout = layout, delim = delim, cols = cols, rows = rows }
135-
self.layout = self:compute_layout()
135+
self.wrap_layout = self:compute_wrap_layout()
136136

137137
-- When wrapping, update col widths so delimiter/border rendering
138138
-- uses the capped widths (padding is included in col width).
139-
if self.layout.wrap then
140-
for i, w in ipairs(self.layout.col_widths) do
139+
if self.wrap_layout.enabled then
140+
for i, w in ipairs(self.wrap_layout.col_widths) do
141141
self.data.cols[i].width = w + 2 * self.config.padding
142142
end
143143
end
@@ -146,9 +146,9 @@ function Render:setup()
146146
end
147147

148148
---@private
149-
---@return render.md.table.Layout
150-
function Render:compute_layout()
151-
local no_wrap = { wrap = false, col_widths = {}, row_heights = {} }
149+
---@return render.md.table.WrapLayout
150+
function Render:compute_wrap_layout()
151+
local no_wrap = { enabled = false, col_widths = {}, row_heights = {} }
152152

153153
-- Feature disabled when max_table_width is 0 (unset)
154154
if self.config.max_table_width == 0 then
@@ -262,7 +262,7 @@ function Render:compute_layout()
262262
return no_wrap
263263
end
264264

265-
return { wrap = true, col_widths = col_widths, row_heights = row_heights }
265+
return { enabled = true, col_widths = col_widths, row_heights = row_heights }
266266
end
267267

268268
---@private
@@ -476,7 +476,7 @@ end
476476

477477
---@protected
478478
function Render:run()
479-
if self.layout.wrap then
479+
if self.wrap_layout.enabled then
480480
self:wrapped()
481481
return
482482
end
@@ -686,7 +686,7 @@ end
686686
---@param row_index integer
687687
---@return render.md.Line[]
688688
function Render:row_wrapped_lines(row, row_index)
689-
local height = self.layout.row_heights[row_index]
689+
local height = self.wrap_layout.row_heights[row_index]
690690
local header = row.node.type == 'pipe_table_header'
691691
local highlight = header and self.config.head or self.config.row
692692
local border_icon = self.config.border[10]
@@ -697,8 +697,10 @@ function Render:row_wrapped_lines(row, row_index)
697697
-- Pre-compute wrapped display lines for each cell in this row
698698
local cell_lines = {} ---@type render.md.Line[][]
699699
for i, cell in ipairs(row.cells) do
700-
cell_lines[i] =
701-
self:wrap_line(self:cell_line(cell.node), self.layout.col_widths[i])
700+
cell_lines[i] = self:wrap_line(
701+
self:cell_line(cell.node),
702+
self.wrap_layout.col_widths[i]
703+
)
702704
end
703705

704706
local filler = self.config.filler
@@ -707,7 +709,7 @@ function Render:row_wrapped_lines(row, row_index)
707709
local line = self:line()
708710
line:pad(spaces, filler)
709711
for i, _ in ipairs(self.data.cols) do
710-
local col_width = self.layout.col_widths[i]
712+
local col_width = self.wrap_layout.col_widths[i]
711713
line:text(border_icon, highlight)
712714
line:pad(padding, filler)
713715
local chunk = cell_lines[i][visual_line + 1] or Line.new(filler)
@@ -893,7 +895,7 @@ function Render:border()
893895
})
894896
else
895897
local col = 0
896-
if not above and self.layout.wrap then
898+
if not above and self.wrap_layout.enabled then
897899
-- Place after wrapped row virtual lines at column 0.
898900
col = node.end_col
899901
end

0 commit comments

Comments
 (0)