diff --git a/dir_entry.go b/dir_entry.go index 59fbcac..e693f86 100644 --- a/dir_entry.go +++ b/dir_entry.go @@ -141,13 +141,6 @@ func (e *DirectoryEntry) SetRemovalMark(mark bool) { for _, entry := range e.Entries() { entry.SetRemovalMark(mark) } - - if e.Parent() != nil { - pentries := e.Parent().Entries() - sort.Slice(pentries, func(i, j int) bool { - return pentries[i].SizeModified() < pentries[j].SizeModified() - }) - } } func (e *DirectoryEntry) RemovalMark() bool { @@ -166,6 +159,12 @@ func (e *DirectoryEntry) modifySize(modifier uint64) { *e.modSize += modifier if e.parent != nil { e.parent.modifySize(modifier) + + // recalculate order of parent entries + pentries := e.Parent().Entries() + sort.Slice(pentries, func(i, j int) bool { + return pentries[i].SizeModified() < pentries[j].SizeModified() + }) } } diff --git a/file_entry.go b/file_entry.go index b749b53..95bf23a 100644 --- a/file_entry.go +++ b/file_entry.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "sort" "strings" ) @@ -117,6 +118,12 @@ func (e *FileEntry) SetRemovalMark(mark bool) { } else { e.modifySize(*e.size) } + + // recalculate order of parent entries + pentries := e.Parent().Entries() + sort.Slice(pentries, func(i, j int) bool { + return pentries[i].SizeModified() < pentries[j].SizeModified() + }) } func (e *FileEntry) RemovalMark() bool { diff --git a/main.go b/main.go index 6209a62..3d8d7ac 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,12 @@ var ( IconTheme = flag.String("i", "unicode", "icon theme (currently supported: default, unicode, nerd)") ) +// FIXME sometimes sorting not applied after removing items +// TODO pwd command showing Current entry path and Root entry path in filesystem +// TODO arrow up -> last command (`stty -raw` necessary?). even better: rlwrap impl (see tsoding noq) +// TODO config file with preferred icon theme or read best icon theme from terminfo somehow +// TODO on exit: show deleted files in recursive tree (only deleted files and their parent directories) +// TODO autocomplete on TAB (see arrow up issue: raw necessary?) func main() { flag.Parse() rootPath := flag.Arg(0)