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

Keybind next-file jumps to wrong file #606

Closed
vanbang9710 opened this issue Aug 18, 2023 · 8 comments
Closed

Keybind next-file jumps to wrong file #606

vanbang9710 opened this issue Aug 18, 2023 · 8 comments

Comments

@vanbang9710
Copy link

  • My config file portable_config.zip. I already unloaded all scripts excepts for uosc
  • My keybind Shift+n script-binding uosc/next-file; script-message-to uosc flash-elements top_bar,timeline #! Navigation > Next File
  • Open 01_welcome.mp4. This directory is 69MB so I don't know how to share it |50pct
  • Spam Shift+n, look at the top bar to see what file is opened. The order seems to not even follow a cycle. |50pct
@christoph-heinrich
Copy link
Contributor

When you browse files with open-file, is the sorting correct there?

@vanbang9710
Copy link
Author

Oh, I forgot to mention that |50pct

@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Aug 21, 2023

I've now looked into this a bit and it works perfectly fine for me, the files get sorted correctly and everything.
Are you sure you don't have shuffle on?

@tomasklaen I haven't actually tested this, but I'm pretty sure that symbol order thing is completely useless right now. We always pass absolute paths to the sorting function, and the symbol order is only respected for the first character of that path. No one ever even noticed apparently, so should we remove that and just use the exact same sorting as autoload.lua?

@tomasklaen
Copy link
Owner

To remove instead of fix symbol sorting if none cares for it: sure

And by autoload sorting, you mean this?

function splitbynum(s)
    local result = {}
    for x, y in (s or ""):gmatch("(%d*)(%D*)") do
        if x ~= "" then table.insert(result, tonumber(x)) end
        if y ~= "" then table.insert(result, y) end
    end
    return result
end

function clean_key(k)
    k = (' '..k..' '):gsub("%s+", " "):sub(2, -2):lower()
    return splitbynum(k)
end

-- compare two strings
function alnumcomp(x, y)
    local xt, yt = clean_key(x), clean_key(y)
    for i = 1, math.min(#xt, #yt) do
        local xe, ye = xt[i], yt[i]
        if type(xe) == "string" then ye = tostring(ye)
        elseif type(ye) == "string" then xe = tostring(xe) end
        if xe ~= ye then return xe < ye end
    end
    return #xt < #yt
end

How is it better than what we have? It's doing some magicky things, so I can't tell. And wouldn't it be slower? It seems to create 2 tables for each comparison, while we create one table per item once.

@christoph-heinrich
Copy link
Contributor

And by autoload sorting, you mean this?

What I mean is this. It's already the same algorithm, with the same optimizations, the only difference is that uosc also has the symbol order.

@vanbang9710
Copy link
Author

May I ask if the merge fixes the problem? If so, I will try it.

@christoph-heinrich
Copy link
Contributor

May I ask if the merge fixes the problem? If so, I will try it.

No, and I honestly doubt there actually is any problem. You probably have shuffle turned on.

@vanbang9710
Copy link
Author

Indeed but I think shuffle should only apply to the keybind "next" instead of next-file

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

3 participants