Toggling sort order fails because M.get_next_sort_order() returns nil.
Opened this issue · 0 comments
I've looked into the issue and I think I found a fix, before creating the PR I want to confirm that this isn't an issue only I'm experiencing.
my set up is taken from the README, haven't done anything special to it.
and it works as expected expect when trying to change how the list is sorted.(:DiredToggleSortOrder or pressing ',')
it fails because M.get_next_sort_order() returns nil.
function M.get_next_sort_order()
local current = vim.g.dired_sort_order
local sorting_functions = { "name", "date", "dirs" }
local idx = 0
for i, str in ipairs(sorting_functions) do
if str == current then
table.remove(sorting_functions, i)
idx = i
end
end
if idx > #sorting_functions then
idx = 1
end
return sorting_functions[idx]
end
E5108: Error executing lua attempt to compare two table values
stack traceback:
[C]: in function 'sort'
.../.local/share/nvim/lazy/dired.nvim/lua/dired/display.lua:91: in function 'get_directory_listing'
.../.local/share/nvim/lazy/dired.nvim/lua/dired/display.lua:144: in function 'display_dired_listing'
.../.local/share/nvim/lazy/dired.nvim/lua/dired/display.lua:25: in function 'render'
...on/.local/share/nvim/lazy/dired.nvim/lua/dired/dired.lua:198: in function 'toggle_sort_order'
[string ":lua"]:1: in main chunk