Skip to content
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

Toggling sort order fails because M.get_next_sort_order() returns nil. #15

Open
noittaM opened this issue Aug 13, 2024 · 0 comments
Open

Comments

@noittaM
Copy link

noittaM commented Aug 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant