From a41408ce7d65b0f6e63dfcd3f4195130180fe076 Mon Sep 17 00:00:00 2001 From: Trent Howard Date: Wed, 8 Jul 2026 21:19:18 +1000 Subject: [PATCH 1/2] fix: truncated block headings when nested in list items or quotes Offset background win_col and border padding by node.start_col so block-width headings nested in list items or quotes render at full width instead of being truncated by the indentation. --- .../render/markdown/heading.lua | 7 +- tests/heading_spec.lua | 77 +++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/lua/render-markdown/render/markdown/heading.lua b/lua/render-markdown/render/markdown/heading.lua index 50cabe9f..7068e540 100644 --- a/lua/render-markdown/render/markdown/heading.lua +++ b/lua/render-markdown/render/markdown/heading.lua @@ -224,7 +224,10 @@ function Render:background(box) local win_col = 0 if self.data.width == 'block' then padding:pad(vim.o.columns * 2) - win_col = box.margin + box.body + self:indent():size(self.data.level) + win_col = self.node.start_col + + box.margin + + box.body + + self:indent():size(self.data.level) end local col = self.node.start_col for row = self.node.start_row, self.node.end_row - 1 do @@ -276,7 +279,7 @@ function Render:border(box, above) local width = self.data.width == 'block' and box.body or vim.o.columns local icon = above and self.config.above or self.config.below - local line = self:line():pad(box.margin) + local line = self:line():pad(self.node.start_col):pad(box.margin) line:rep(icon, box.padding, bg) line:rep(icon, prefix, fg) line:rep(icon, width - box.padding - prefix, bg) diff --git a/tests/heading_spec.lua b/tests/heading_spec.lua index 538e8d1c..45586433 100644 --- a/tests/heading_spec.lua +++ b/tests/heading_spec.lua @@ -21,6 +21,11 @@ describe('heading', function() 'Ext Heading 2', 'Ext Heading 2 Line 2', '---', + '', + '- # Heading', + ' - ## Heading 2', + '', + '> # Quote heading', } it('default', function() @@ -43,6 +48,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -73,6 +83,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -103,6 +122,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -126,6 +154,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -161,6 +194,17 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + '', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -191,6 +235,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -214,6 +267,11 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + '', + '󰫎 ● Heading 󰲡', + '󰫎 ○ Heading 2 󰲣', + '', + '󰫎 ▋ Quote heading 󰲡', }) end) @@ -244,6 +302,15 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄▄', + '󰫎 ● Heading 󰲡', + ' ▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ Heading 2 󰲣', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ Quote heading 󰲡', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -267,6 +334,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -290,6 +362,11 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + '', + '󰫎 ● Heading 󰲡', + '󰫎 ○ Heading 2 󰲣', + '', + '󰫎 ▋ Quote heading 󰲡', }) end) end) From b3e3de3b35bda1ea4e76a3266f7b79fa0e83364e Mon Sep 17 00:00:00 2001 From: Trent Howard Date: Wed, 8 Jul 2026 22:42:11 +1000 Subject: [PATCH 2/2] fix: increase test screen size to prevent status line being captured --- tests/minimal_init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua index fc6621c5..b5449db5 100644 --- a/tests/minimal_init.lua +++ b/tests/minimal_init.lua @@ -12,7 +12,7 @@ end -- settings vim.o.columns = 80 -vim.o.lines = 40 +vim.o.lines = 60 vim.o.tabstop = 4 vim.o.wrap = false