@@ -71,13 +71,30 @@ M.render_heading = function(buf, info)
7171 local icon = list .cycle (heading .icons , level )
7272 local background = list .clamp (heading .backgrounds , level )
7373
74- -- Available width is level + 1 - concealed, where level = number of `#` characters, one
75- -- is added to account for the space after the last `#` but before the heading title,
76- -- and concealed text is subtracted since that space is not usable
77- local padding = level + 1 - ts .concealed (buf , info ) - str .width (icon )
78- if padding < 0 then
79- -- Requires inline extmarks to place when there is not enough space available
80- if util .has_10 then
74+ if icon then
75+ -- Available width is level + 1 - concealed, where level = number of `#` characters, one
76+ -- is added to account for the space after the last `#` but before the heading title,
77+ -- and concealed text is subtracted since that space is not usable
78+ local padding = level + 1 - ts .concealed (buf , info ) - str .width (icon )
79+ if padding < 0 then
80+ -- Requires inline extmarks to place when there is not enough space available
81+ if util .has_10 then
82+ --- @type render.md.Mark
83+ local icon_mark = {
84+ conceal = true ,
85+ start_row = info .start_row ,
86+ start_col = info .start_col ,
87+ opts = {
88+ end_row = info .end_row ,
89+ end_col = info .end_col ,
90+ virt_text = { { icon , { foreground , background } } },
91+ virt_text_pos = ' inline' ,
92+ conceal = ' ' ,
93+ },
94+ }
95+ list .add (marks , icon_mark )
96+ end
97+ else
8198 --- @type render.md.Mark
8299 local icon_mark = {
83100 conceal = true ,
@@ -86,27 +103,12 @@ M.render_heading = function(buf, info)
86103 opts = {
87104 end_row = info .end_row ,
88105 end_col = info .end_col ,
89- virt_text = { { icon , { foreground , background } } },
90- virt_text_pos = ' inline' ,
91- conceal = ' ' ,
106+ virt_text = { { str .pad (icon , padding ), { foreground , background } } },
107+ virt_text_pos = ' overlay' ,
92108 },
93109 }
94110 list .add (marks , icon_mark )
95111 end
96- else
97- --- @type render.md.Mark
98- local icon_mark = {
99- conceal = true ,
100- start_row = info .start_row ,
101- start_col = info .start_col ,
102- opts = {
103- end_row = info .end_row ,
104- end_col = info .end_col ,
105- virt_text = { { str .pad (icon , padding ), { foreground , background } } },
106- virt_text_pos = ' overlay' ,
107- },
108- }
109- list .add (marks , icon_mark )
110112 end
111113 --- @type render.md.Mark
112114 local background_mark = {
0 commit comments