diff --git a/CHANGELOG.md b/CHANGELOG.md index 904ef262..be1849f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): - Smart-case in interactive `cd` broken due to a typo ([#3540]) - Fix shell formatting for non-spread opener rules ([#3532]) +- `sort extension` excludes directories since only files have extensions ([#3582]) - Account for URL covariance in `Url:join()` ([#3514]) ## [v26.1.4] @@ -340,7 +341,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): ### Fixed -- `before_ext` should exclude directories since only files have extensions ([#2132]) +- `before_ext` excludes directories since only files have extensions ([#2132]) - Element style of `ui.Text` was not applied to the entire area ([#2093]) - Incorrect monorepo sub-plugin path resolution ([#2186]) - Use `u32` for parsing Linux partition blocks ([#2234]) @@ -1605,3 +1606,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3541]: https://github.com/sxyazi/yazi/pull/3541 [#3561]: https://github.com/sxyazi/yazi/pull/3561 [#3566]: https://github.com/sxyazi/yazi/pull/3566 +[#3582]: https://github.com/sxyazi/yazi/pull/3582 diff --git a/yazi-fs/src/sorter.rs b/yazi-fs/src/sorter.rs index 2d745dc7..5f189d2f 100644 --- a/yazi-fs/src/sorter.rs +++ b/yazi-fs/src/sorter.rs @@ -40,12 +40,14 @@ impl FilesSorter { if ord == Ordering::Equal { by_alphabetical(a, b) } else { ord } }), SortBy::Extension => items.sort_unstable_by(|a, b| { + let aa = a.url.ext().filter(|_| a.is_file()); + let bb = b.url.ext().filter(|_| b.is_file()); let ord = if self.sensitive { - self.cmp(a.url.ext(), b.url.ext(), self.promote(a, b)) + self.cmp(aa, bb, self.promote(a, b)) } else { self.cmp_insensitive( - a.url.ext().map_or(&[], |s| s.encoded_bytes()), - b.url.ext().map_or(&[], |s| s.encoded_bytes()), + aa.map_or(&[], |s| s.encoded_bytes()), + bb.map_or(&[], |s| s.encoded_bytes()), self.promote(a, b), ) };