kyoheiu / felix

tui file manager with vim-like key mapping
https://kyoheiu.dev/felix/
MIT License
729 stars 26 forks source link

Order of files in directory #149

Closed balroggg closed 1 year ago

balroggg commented 1 year ago

Order of files in felix, for example root of this repository:

..
README.md
config.yaml <---

Order of files in ls(kinda reverse) or ranger:

ls -1
Cargo.lock
Cargo.toml
CHANGELOG.md
config.yaml <---
LICENSE
README.md
...

Is this intentional or just random choice? Maybe consider sort files in the same(alphabet order if I not wrong) order?

balroggg commented 1 year ago

Maybe use natord::compare_ignore_case instead of natord::compare in state.rs

kyoheiu commented 1 year ago

Interesting. This didn't came to my mind, but yes felix sorts in the different way.

ls default:

drwxr-xr-x  8 kyohei kyohei  4096 Nov 19 06:54 .
drwxr-xr-x 15 kyohei kyohei  4096 Nov  3 14:00 ..
-rw-r--r--  1 kyohei kyohei 31713 Nov 19 06:54 Cargo.lock
-rw-r--r--  1 kyohei kyohei   896 Nov 19 06:54 Cargo.toml
-rw-r--r--  1 kyohei kyohei 15350 Nov 19 06:54 CHANGELOG.md
-rw-r--r--  1 kyohei kyohei  1621 Nov 19 06:54 config.yaml
drwxr-xr-x  8 kyohei kyohei  4096 Nov 19 06:58 .git
drwxr-xr-x  3 kyohei kyohei  4096 Apr 15  2022 .github
-rw-r--r--  1 kyohei kyohei    28 Nov 19 06:54 .gitignore
-rw-r--r--  1 kyohei kyohei  1067 Nov 10  2021 LICENSE
-rw-r--r--  1 kyohei kyohei  5401 Nov 19 06:54 README.md
drwxr-xr-x  2 kyohei kyohei  4096 Nov 19 06:54 screenshots
drwxr-xr-x  2 kyohei kyohei  4096 Nov 19 06:54 src
drwxr-xr-x  5 kyohei kyohei  4096 Nov 11 17:59 target
drwxr-xr-x  4 kyohei kyohei  4096 Nov 18 10:33 testfiles

Seems ls also ignores prefix dot, so will need to use strip_prefix(|x| ...).

Personally I'm too accustomed to this order: Especially, I feet it's good to sort all dot files before others. But it may be worth getting align with ls's default.

I'd like to hear what others have to say about this.

kyoheiu commented 1 year ago

Or just adding its own configuration, like "ls / alphabetical (dot first) / alphabetical (dot last)...", may work.

balroggg commented 1 year ago

I'm talking more about order in files or directories without hidden files or unrelated to them.

Order in ls: Cargo.lock Cargo.toml CHANGELOG.md config.yaml LICENSE README.md CH.. -> co..

Order in felix: Cargo.lock Cargo.toml CHANGELOG.md LICENSE README.md config.yaml CH.. -> LI..

balroggg commented 1 year ago

I'm ok with order of hidden files :smile:

kyoheiu commented 1 year ago

I'm talking more about order in files or directories without hidden files or unrelated to them.

Ok, I understand. But if we consider under the rule of ls, the position of hidden files should be also taken care... (Or shouldn't it?)

If I leave hidden files untouched, it goes like this:

drwxr-xr-x  8 kyohei kyohei  4096 Nov 19 06:58 .git
drwxr-xr-x  3 kyohei kyohei  4096 Apr 15  2022 .github
-rw-r--r--  1 kyohei kyohei    28 Nov 19 06:54 .gitignore
-rw-r--r--  1 kyohei kyohei 31713 Nov 19 06:54 Cargo.lock
-rw-r--r--  1 kyohei kyohei   896 Nov 19 06:54 Cargo.toml
-rw-r--r--  1 kyohei kyohei 15350 Nov 19 06:54 CHANGELOG.md
-rw-r--r--  1 kyohei kyohei  1621 Nov 19 06:54 config.yaml
-rw-r--r--  1 kyohei kyohei  1067 Nov 10  2021 LICENSE
-rw-r--r--  1 kyohei kyohei  5401 Nov 19 06:54 README.md
drwxr-xr-x  2 kyohei kyohei  4096 Nov 19 06:54 screenshots
drwxr-xr-x  2 kyohei kyohei  4096 Nov 19 06:54 src
drwxr-xr-x  5 kyohei kyohei  4096 Nov 11 17:59 target
drwxr-xr-x  4 kyohei kyohei  4096 Nov 18 10:33 testfiles

Well, that's fine, I like it. But not ls-like yet. Anyway, I want more from others on this. Will keep this open.

kyoheiu commented 1 year ago

Changed: 50c48fe436d427ab3869177d4fc070443077915d