Skip to content

Commit 56d92af

Browse files
fix: Marks on current row should only be hidden for current buffer
## Details Currently when LSP signature help is opened the first line virtual text is hidden. This is because the cursor for that buffer is on the first line, however this should not matter since that buffer is not active. To fix this check whether the buffer being rendered is the current buffer when getting the cursor position. If it is not the current buffer use nil as the row value and render marks when row is nil. Refactor the logic for showing vs. hiding a mark into a local function rather than a large if statement. This lets us comment what's going on and I have a feeling that logic will need to evolve in other ways over time. Add a todo doc to keep track of various ideas that I haven't fully ruled out implementing. Add plugin configuration and checkboxes of confirmations as fields to bug report template.
1 parent ff1b449 commit 56d92af

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,22 @@ body:
3535
required: true
3636
- type: textarea
3737
attributes:
38-
label: Healthcheck output (:checkhealth render-markdown)
38+
label: Healthcheck output
39+
description: Output of :checkhealth render-markdown
3940
validations:
4041
required: true
42+
- type: textarea
43+
attributes:
44+
label: Plugin configuration
45+
description: Your configuration for this plugin.
46+
validations:
47+
required: true
48+
- type: checkboxes
49+
attributes:
50+
label: Confirmations
51+
options:
52+
- label: I have provided markdown text for any screenshots used in my description & understand that my issue will be closed if I have not
53+
required: true
4154
- type: textarea
4255
attributes:
4356
label: Additional information

doc/todo.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# TODOs
2+
3+
- See if there is a stable way to align table cells according to delimiter
4+
alignment info.
5+
- Add a performance test suite to measure improvements, relative value on
6+
same hardware should still be useful.

lua/render-markdown/ui.lua

+23-3
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,30 @@ M.refresh = function(buf, mode, parse)
7878
cache.marks[buf] = marks
7979
end
8080

81-
-- Render marks based on anti-conceal behavior and current row
82-
local row = vim.api.nvim_win_get_cursor(util.buf_to_win(buf))[1] - 1
81+
---Render marks based on anti-conceal behavior and current row
82+
---@param mark render.md.Mark
83+
---@param row? integer
84+
---@return boolean
85+
local function should_show_mark(mark, row)
86+
-- Anti-conceal is not enabled -> all marks should be shown
87+
if not state.config.anti_conceal.enabled then
88+
return true
89+
end
90+
-- Row is not known means buffer is not active -> all marks should be shown
91+
if row == nil then
92+
return true
93+
end
94+
-- Mark is not concealable -> mark should always be shown
95+
if not mark.conceal then
96+
return true
97+
end
98+
-- Show mark if it is not on the current row
99+
return mark.start_row ~= row
100+
end
101+
102+
local row = util.cursor_row(buf)
83103
for _, mark in ipairs(marks) do
84-
if not state.config.anti_conceal.enabled or not mark.conceal or mark.start_row ~= row then
104+
if should_show_mark(mark, row) then
85105
-- Only ensure strictness if the buffer was parsed this request
86106
-- The order of events can cause our cache to be stale
87107
mark.opts.strict = parse

lua/render-markdown/util.lua

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ M.buf_to_win = function(buf)
1818
return vim.fn.bufwinid(buf)
1919
end
2020

21+
---@param buf integer
22+
---@return integer?
23+
M.cursor_row = function(buf)
24+
if vim.api.nvim_get_current_buf() ~= buf then
25+
return nil
26+
end
27+
return vim.api.nvim_win_get_cursor(M.buf_to_win(buf))[1] - 1
28+
end
29+
2130
---@param buf integer
2231
---@return integer
2332
M.get_width = function(buf)

0 commit comments

Comments
 (0)