Skip to content

fix(command): redo fallback mechanism #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/neo-tree/sources/common/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ M.toggle_preview = function(state)
Preview.toggle(state)
end

M.scroll_preview = function(state, fallback)
Preview.scroll(state, fallback)
M.scroll_preview = function(state)
Preview.scroll(state)
end

M.focus_preview = function()
Expand Down
4 changes: 2 additions & 2 deletions lua/neo-tree/sources/common/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ end

local CTRL_E = utils.keycode("<c-e>")
local CTRL_Y = utils.keycode("<c-y>")
Preview.scroll = function(state, fallback)
Preview.scroll = function(state)
local direction = state.config.direction
local input = direction < 0 and CTRL_E or CTRL_Y
local count = math.abs(direction)
Expand All @@ -502,7 +502,7 @@ Preview.scroll = function(state, fallback)
end)
else
vim.api.nvim_buf_call(state.bufnr, function()
vim.cmd(("normal! %s"):format(utils.keycode(fallback)))
vim.cmd(("normal! %s"):format(utils.keycode(state.fallback)))
end)
end
end
Expand Down
3 changes: 2 additions & 1 deletion lua/neo-tree/ui/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ local set_buffer_mappings = function(state)
if type(func) == "function" then
resolved_mappings[cmd].handler = function()
state.config = config
return func(state, cmd)
state.fallback = cmd
return func(state)
end
keymap.set(state.bufnr, "n", cmd, resolved_mappings[cmd].handler, map_options)
if type(vfunc) == "function" then
Expand Down