Skip to content

Commit

Permalink
normalize case for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-hao committed May 10, 2024
1 parent dac7ee3 commit 28ec469
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions chadtree/view/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def cont() -> Iterator[Any]:
yield _CompVals.FOLDER if is_dir(node) else _CompVals.FILE
elif sb is Sortby.ext:
yield "" if is_dir(node) else _suffixx(node.path)
elif sb is Sortby.file_name_lower:
yield strxfrm(node.path.name.casefold())
elif sb is Sortby.file_name:
yield strxfrm(node.path.name)
else:
Expand Down
1 change: 1 addition & 0 deletions chadtree/view/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HLcontext:
class Sortby(Enum):
is_folder = auto()
ext = auto()
file_name_lower = auto()
file_name = auto()


Expand Down
1 change: 1 addition & 0 deletions config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ view:
sort_by:
- is_folder
- ext
- file_name_lower
- file_name
time_format: "%Y-%m-%d %H:%M"
width: 40
Expand Down
4 changes: 2 additions & 2 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ CHADTree can sort by the following criterion. Reorder them if you want a differe
**legal keys: some of**

```json
["is_folder", "ext", "file_name"]
["is_folder", "ext", "file_name_lower", "file_name"]
```

**default:**

```json
["is_folder", "ext", "file_name"]
["is_folder", "ext", "file_name_lower", "file_name"]
```

#### `chadtree_settings.view.width`
Expand Down

0 comments on commit 28ec469

Please sign in to comment.