Skip to content

Commit 33456cb

Browse files
fix: stabilize inline virt_text ordering at shared positions in table renderer
Neovim's mark tree traversal order is not stable for inline virt_text when range marks (conceal+border) and point marks (padding/decoration) coexist at the same (row, col). The traversal order depends on the internal tree structure, which varies with the total number of marks in the buffer. In hybrid mode, filtering out preceding content changes how many marks are created, shifting the mark tree structure and causing padding/decoration marks to swap visual order with junction/border marks at shared positions. This made table borders appear misplaced when the cursor was on a heading or inside a nearby table. Fix: set right_gravity=false on all inline padding/decoration marks at col_end positions (header row and separator row). Neovim sorts right_gravity=false before right_gravity=true at the same position, guaranteeing stable traversal order regardless of tree structure.
1 parent 52f7156 commit 33456cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/markview/renderers/markdown.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ markdown.table = function (buffer, item)
18571857
{ string.rep(" ", math.max(0, column_width - visible_width)) }
18581858
},
18591859

1860+
right_gravity = false,
18601861
hl_mode = "combine"
18611862
});
18621863
elseif item.alignments[c] == "right" then
@@ -1867,6 +1868,7 @@ markdown.table = function (buffer, item)
18671868
{ string.rep(" ", math.max(0, column_width - visible_width)) }
18681869
},
18691870

1871+
right_gravity = false,
18701872
hl_mode = "combine"
18711873
});
18721874
else
@@ -1877,6 +1879,7 @@ markdown.table = function (buffer, item)
18771879
{ string.rep(" ", math.ceil((column_width - visible_width) / 2)) }
18781880
},
18791881

1882+
right_gravity = false,
18801883
hl_mode = "combine"
18811884
});
18821885
vim.api.nvim_buf_set_extmark(buffer, markdown.ns, range.row_start, range.col_start + part.col_end, {
@@ -1886,6 +1889,7 @@ markdown.table = function (buffer, item)
18861889
{ string.rep(" ", math.floor((column_width - visible_width) / 2)) }
18871890
},
18881891

1892+
right_gravity = false,
18891893
hl_mode = "combine"
18901894
});
18911895
end
@@ -1967,6 +1971,7 @@ markdown.table = function (buffer, item)
19671971
{ string.rep(border, left), utils.set_hl(border_hl) },
19681972
},
19691973

1974+
right_gravity = false,
19701975
hl_mode = "combine"
19711976
});
19721977
else
@@ -2014,6 +2019,7 @@ markdown.table = function (buffer, item)
20142019
{ string.rep(border, left), utils.set_hl(border_hl) },
20152020
},
20162021

2022+
right_gravity = false,
20172023
hl_mode = "combine"
20182024
});
20192025
else
@@ -2062,6 +2068,7 @@ markdown.table = function (buffer, item)
20622068
{ align, utils.set_hl(align_hl) }
20632069
},
20642070

2071+
right_gravity = false,
20652072
hl_mode = "combine"
20662073
});
20672074
else
@@ -2111,6 +2118,7 @@ markdown.table = function (buffer, item)
21112118
{ align[2], utils.set_hl(align_hl[2]) }
21122119
},
21132120

2121+
right_gravity = false,
21142122
hl_mode = "combine"
21152123
});
21162124
else

0 commit comments

Comments
 (0)