| Summary: | Sorting by file extension should put empty extensions first | ||
|---|---|---|---|
| Product: | [Applications] krusader | Reporter: | Wladimir Palant <psbkde> |
| Component: | general | Assignee: | Krusader Bugs Distribution List <krusader-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | krusader-bugs-null |
| Priority: | NOR | ||
| Version First Reported In: | Git | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/krusader/1db4a2b8a3e6de837fea5a90988cc5576de52ea7 | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
| Attachments: | Proposed patch | ||
|
Description
Wladimir Palant
2017-02-01 11:01:26 UTC
Created attachment 103745 [details] Proposed patch Here is a fix for this issue. Note that it is treating the case where both strings are equal specially, this is for consistency with the logic at the bottom of compareTextsAlphabetical() and compareTextsCharacterCode(). I don't see a difference if I leave out this case but if it is important then personally I would have written this differently: > if (aS2.length() == 0) { > return false; > } else if (aS1.length() == 0) { > return true; > } The checks in compareTextsAlphabetical() can be simplified similarly: > if (lPositionS2 == aS2.length()) return false; > else if (lPositionS1 == aS1.length()) return true; These two comparisons produce the same result as the six comparisons currently there. Now that I figured out how to register for Phabricator I created a proper review: https://phabricator.kde.org/D4417 Git commit 1db4a2b8a3e6de837fea5a90988cc5576de52ea7 by Alexander Bikadorov, on behalf of Wladimir Palant.
Committed on 13/02/2017 at 20:34.
Pushed by abikadorov into branch 'master'.
#375831 - Sort empty file extensions correctly
Summary:
This change makes sure that empty strings are sorted before non-empty strings. Note that it is treating the case where both strings are equal specially, this is for consistency with the logic at the bottom of compareTextsAlphabetical() and compareTextsCharacterCode(). I don't see a difference if I leave out this case but if it is important then personally I would have written this differently:
```
if (aS2.length() == 0) {
return false;
} else if (aS1.length() == 0) {
return true;
}
```
The checks in compareTextsAlphabetical() can be simplified similarly:
```
if (lPositionS2 == aS2.length()) return false;
else if (lPositionS1 == aS1.length()) return true;
```
These two comparisons produce the same result as the six comparisons currently there.
Test Plan: See STR in bug.
Reviewers: #krusader, martinkostolny, abika, asensi
Reviewed By: #krusader, martinkostolny, abika, asensi
Subscribers: asensi, martinkostolny, #krusader
Tags: #krusader
Differential Revision: https://phabricator.kde.org/D4417
M +5 -4 krusader/Panel/krsort.cpp
https://commits.kde.org/krusader/1db4a2b8a3e6de837fea5a90988cc5576de52ea7
|