Skip to content

Multi-selected files open in random order, not by name #6087

Description

@jeet0474

Is your feature request related to a problem? Please describe.
I open a folder, say D:\@ML\module1, select lec1 to lec8, hit Enter. Tabs open all scattered. Not lec1, lec2, lec3. Just random.

And no it's not my clicking. I tried selecting them in order too. Still scattered. So it's not selection order. Sumatra just takes whatever order Windows gives.

I looked into it a bit. The Windows file picker returns files in some shell order thats not name order and not click order. Then StartLoadDocuments in src/SumatraPDF.cpp just makes tabs in that same order. Drag and drop does the same thing since it goes through the same function.

Describe the solution you'd like
Just sort the list before making tabs. The helper already exists (SortNatural in src/base/StrVec.cpp) and is already used in the same file. One line, right after pathsToLoad is built (around line 4493):

if (pathsToLoad.IsEmpty()) {
    return;
}
SortNatural(&pathsToLoad);   // open tabs in name order (lec1, lec2, ... lec10)

Its natural sort so lec2 comes before lec10, not the dumb lec1, lec10, lec2.

Describe alternatives you've considered
Maybe hide it behind a setting if someone actually likes the random/time/selection/etc order. Ill let you decide. For me name order is just the obvious thing when opening a pile of lectures.

Additional context
So yeah. I found the bug, traced it, wrote the fix. But I am not gonna install the whole Visual Studio build setup just to test ONE line lol. By the time I clone the repo you could already have it built. So here, free diagnosis and a one liner, im just gonna leave this here and slowly walk away 😄

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions