Skip to content

Commit 467ad24

Browse files
Use full mode when deciding to render or not
resolves: #43 # Details Currently we truncate mode to the first character when deciding to render or not. This reduces the amount of control we have, as described in the issue above, where not rendering during operator pending mode `no` would improve navigation. The fix is to remove any truncation logic so we access the full mode. This on its own handles operator pending correctly as `no` mode is no longer considered a render mode. So the defaults do not change. There could be some edge cases that crop up with different mode combinations so may need to update the default set of rendered modes, but seems to work as expected from some basic use.
1 parent 6eef62c commit 467ad24

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lua/render-markdown/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ function M.setup(opts)
247247
group = group,
248248
callback = function(event)
249249
local render_modes = state.config.render_modes
250-
local prev_rendered = vim.tbl_contains(render_modes, string.sub(vim.v.event.old_mode, 1, 1))
251-
local should_render = vim.tbl_contains(render_modes, string.sub(vim.v.event.new_mode, 1, 1))
250+
local prev_rendered = vim.tbl_contains(render_modes, vim.v.event.old_mode)
251+
local should_render = vim.tbl_contains(render_modes, vim.v.event.new_mode)
252252
-- Only need to re-render if render state is changing. I.e. going from normal mode to
253253
-- command mode with the default config, both are rendered, so no point re-rendering
254254
if prev_rendered ~= should_render then

lua/render-markdown/ui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ M.namespace = vim.api.nvim_create_namespace('render-markdown.nvim')
1616

1717
---@param buf integer
1818
M.schedule_refresh = function(buf)
19-
local mode = vim.fn.mode()
19+
local mode = vim.fn.mode(true)
2020
vim.schedule(function()
2121
M.refresh(buf, mode)
2222
end)

0 commit comments

Comments
 (0)