Fix image navigation order: natural sort instead of lexicographic#158
Open
Slashxdd wants to merge 1 commit intoModuleArt:feature/new-webp-decoderfrom
Open
Fix image navigation order: natural sort instead of lexicographic#158Slashxdd wants to merge 1 commit intoModuleArt:feature/new-webp-decoderfrom
Slashxdd wants to merge 1 commit intoModuleArt:feature/new-webp-decoderfrom
Conversation
Resolves ModuleArt#146: images now navigate in natural order (1, 2, 101) matching Windows Explorer, instead of lexicographic order (1, 101, 2). Uses StrCmpLogicalW from shlwapi.dll — the same Windows shell function Explorer itself uses for file sorting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #146
Problem
When navigating through images in a folder with arrow buttons, files are ordered lexicographically:
1, 101, 2— instead of the expected natural order1, 2, 101.Root cause
GetCurrentFiles()builds the file list fromDirectory.GetFiles()and returns it as-is, with no sorting applied.Directory.GetFiles()returns files in filesystem/lexicographic order, so multi-digit filenames end up out of order.Fix
Sort the list in
GetCurrentFiles()usingStrCmpLogicalWfromshlwapi.dll— the exact same Windows shell function that File Explorer uses for its own file sorting. This guarantees the navigation order always matches what the user sees in Explorer.One line added to
GetCurrentFiles(), oneDllImportdeclaration, oneusing System.Runtime.InteropServices.