feat(table): add cell wrapping using virt lines#617
feat(table): add cell wrapping using virt lines#617MaxDillon wants to merge 8 commits intoMeanderingProgrammer:mainfrom
Conversation
MeanderingProgrammer
left a comment
There was a problem hiding this comment.
This is a really interesting PR, it's going to take me a bit of time to parse through it.
I appreciate the effort! This could be a truly awesome feature.
| -- | 0.1–1.0 | fraction of window width, e.g. 0.8 = 80% | | ||
| -- | 2+ | absolute character width, e.g. 80 = 80 columns | | ||
| -- | < 0 | window width minus N, e.g. -10 = width minus 10 | | ||
| max_table_width = 0, |
There was a problem hiding this comment.
One minor thing is if this does get merged in we'd definitely enable it by default, probably set the default to 1.0. Unless we feel it's unstable and want to keep stress testing it before switching it on for everyone.
fa67526 to
fb51061
Compare
| -- uses the capped widths (padding is included in delim col width). | ||
| if self.layout.wrap then | ||
| for i, w in ipairs(self.layout.col_widths) do | ||
| self.data.delim.cols[i].width = w + 2 * self.config.padding |
There was a problem hiding this comment.
This implementation (along with the way the line is built) will always add additional padding to cells that do not need it. The point of padding is to make sure that each cell has space around it, i.e. |A| -> | A |.
However if the cell already has padding like | A | it can be kept as is. With this logic it gets changed to | A | (with 2 extra spaces).
| end | ||
|
|
||
| local filler = self.config.filler | ||
| local function build_line(visual_line) |
There was a problem hiding this comment.
This currently doesn't use the alignment signal, not strictly necessary from the start, but we probably wouldn't enable it by default without that. We would probably only try to align cells that are not wrapped.
|
|
||
| ---@private | ||
| ---@return render.md.table.Layout | ||
| function Render:compute_layout() |
There was a problem hiding this comment.
Currently does not handle tables with leading spaces, i.e.
| Col | Col | Col |
| --- | --- | --- |
| Row | Row | Row |
There was a problem hiding this comment.
As far as I can tell it handles tables with spaces gracefully... Is there a specific circumstance you are running into where you are having trouble here?
For me, the original table formatter and the wrapping table formatter both handle spacing up to 3 spaces deep, then they both stop working
Note... When I was testing this and I turned on list chats, I noticed that spaces dont show unless we are actively hovering over the line, as these are constructed lines. not sure if this is a feature or a bug.
9ab4ea7 to
145387c
Compare
145387c to
1da7686
Compare
Closes: #616
What it does
compute_layoutinRenderer:setup()calculates layout (column widths, row heights)