Skip to content

Commit b980eb2

Browse files
committed
Fix sort by dates initial application
1 parent 92988c1 commit b980eb2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kittens/choose_files/scan.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ func (fss *FileSystemScanner) worker() {
296296
return
297297
}
298298
has_git_ignore, has_dot_git, has_dot_ignore := false, false, false
299+
sort_order := 1
299300
for i, e := range entries {
300301
name := e.Name()
301302
ftype := e.Type()
@@ -337,6 +338,7 @@ func (fss *FileSystemScanner) worker() {
337338
}
338339
binary.BigEndian.PutUint64(arena[i].buf[1:], uint64(ts.UnixNano()))
339340
arena[i].sort_key = arena[i].buf[:1+8]
341+
sort_order = -1
340342
} else {
341343
n := as_lower(arena[i].name, arena[i].buf[1:])
342344
arena[i].sort_key = arena[i].buf[:1+n]
@@ -370,7 +372,7 @@ func (fss *FileSystemScanner) worker() {
370372
}
371373
final_entries = ignoreable
372374
}
373-
slices.SortFunc(final_entries, func(a, b *sortable_dir_entry) int { return bytes.Compare(a.sort_key, b.sort_key) })
375+
slices.SortFunc(final_entries, func(a, b *sortable_dir_entry) int { return sort_order * bytes.Compare(a.sort_key, b.sort_key) })
374376
fss.lock()
375377
for _, e := range final_entries {
376378
i := fss.collection.NextAppendPointer()
@@ -662,6 +664,7 @@ func (m *ResultManager) new_scorer() {
662664
m.scorer.respect_ignores = m.settings.RespectIgnores()
663665
m.scorer.show_hidden = m.settings.ShowHidden()
664666
m.scorer.global_ignore = m.settings.GlobalIgnores()
667+
m.scorer.sort_by_last_modified = m.settings.SortByLastModified()
665668
m.last_click_anchor = nil
666669
}
667670

0 commit comments

Comments
 (0)