Skip to content

Commit 7fd9116

Browse files
fix: scope and autolink highlights conflict
## Details Issue: #518 When adding a scope highlight for list items or checkboxes the priority used was the default. This was also the case for the body of autolinks As a result the 2 highlights would conflict with each other and one would be selected at random by neovim. Which one to prefer is not really obvious to me, but to keep the behavior the same as other links the autolink value is now set to a lower value of 1000 (instead of the default of 4096). This means that scope highlights will have a higher priority and be used when rendering the autolink body (if one exists).
1 parent 95994ad commit 7fd9116

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.11.4 Last change: 2025 September 07
1+
*render-markdown.txt* For NVIM v0.11.4 Last change: 2025 September 08
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.7.15'
8+
M.version = '8.7.16'
99

1010
function M.check()
1111
M.start('versions')

lua/render-markdown/render/inline/link.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@ function Render:run()
5454
virt_text_pos = 'inline',
5555
})
5656
if self.data.autolink then
57-
self:hide(self.node.start_col, self.node.start_col + 1)
57+
self:hide(self.node.start_col, 1)
5858
self.marks:over(self.config, 'link', self.node, {
59+
priority = 1000,
5960
hl_group = self.data.icon[2],
6061
})
61-
self:hide(self.node.end_col - 1, self.node.end_col)
62+
self:hide(self.node.end_col - 1, 1)
6263
end
6364
end
6465

6566
---@private
66-
---@param start_col integer
67-
---@param end_col integer
68-
function Render:hide(start_col, end_col)
69-
self.marks:add(self.config, true, self.node.start_row, start_col, {
70-
end_col = end_col,
67+
---@param col integer
68+
---@param length integer
69+
function Render:hide(col, length)
70+
self.marks:add(self.config, true, self.node.start_row, col, {
71+
end_col = col + length,
7172
conceal = '',
7273
})
7374
end

tests/util.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,19 @@ end
7474
---@param kind 'code'|'inline'|'link'
7575
---@return vim.api.keyset.set_extmark
7676
function M.highlight(kind)
77+
local priority ---@type integer?
7778
local highlight ---@type string
7879
if kind == 'code' then
7980
highlight = 'RmCodeInline'
8081
elseif kind == 'inline' then
8182
highlight = 'RmInlineHighlight'
8283
elseif kind == 'link' then
84+
priority = 1000
8385
highlight = 'RmLink'
8486
end
8587
---@type vim.api.keyset.set_extmark
8688
return {
89+
priority = priority,
8790
hl_eol = false,
8891
hl_group = highlight,
8992
}

0 commit comments

Comments
 (0)