Skip to content

Commit

Permalink
fix: opening many files with custom keymappings causing an error
Browse files Browse the repository at this point in the history
The error was tricky to reproduce. Here's what happened:
- open yazi
- select multiple files with space or c-a
- pressing enter will send them to the quickfix list
- alternatively, pressing e.g. c-v can open them in vertical splits
- the next time you opened yazi, the keymappings were not properly
  reset, causing opening many files with enter not to be sent to the
  quickfix list, but to be opened in vertical splits

The error was caused by the fact that the config was modified in the
keymappings, but not properly reset on the next opening of yazi.
  • Loading branch information
mikavilpas committed Apr 19, 2024
1 parent 40eb32c commit 86f3623
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/yazi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ local M = {}

M.yazi_loaded = false

--- :Yazi entry point
---@param config? YaziConfig?
---@param path? string
---@diagnostic disable-next-line: redefined-local
Expand All @@ -18,7 +17,8 @@ function M.yazi(config, path)
return
end

config = vim.tbl_deep_extend('force', M.config, config or {})
config =
vim.tbl_deep_extend('force', configModule.default(), M.config, config or {})

path = utils.selected_file_path(path)

Expand Down Expand Up @@ -65,7 +65,8 @@ M.config = configModule.default()

---@param opts YaziConfig?
function M.setup(opts)
M.config = vim.tbl_deep_extend('force', M.config, opts or {})
M.config =
vim.tbl_deep_extend('force', configModule.default(), M.config, opts or {})

if M.config.open_for_directories == true then
local yazi_augroup = vim.api.nvim_create_augroup('yazi', { clear = true })
Expand Down

0 comments on commit 86f3623

Please sign in to comment.