From a71e97ce4ed4d2d3ce2f0ef3f51358934b398187 Mon Sep 17 00:00:00 2001 From: llyyr Date: Mon, 30 Mar 2026 19:55:29 +0530 Subject: [PATCH 1/2] output: use natural sort for workspace ordering Fixes: https://github.com/mahkoh/jay/issues/843 --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/tree/output.rs | 5 +++-- toml-spec/spec/spec.generated.md | 2 +- toml-spec/spec/spec.yaml | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3943cdc1..17bdbe93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -823,6 +823,7 @@ dependencies = [ "log", "num-derive", "num-traits", + "numeric-sort", "opera", "parking_lot", "pin-project", @@ -1080,6 +1081,12 @@ dependencies = [ "libc", ] +[[package]] +name = "numeric-sort" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dcb6053ab98da45585315f79932c5c9821fab8efa4301c0d7b637c91630eb7" + [[package]] name = "object" version = "0.37.3" diff --git a/Cargo.toml b/Cargo.toml index d531e25a..48ad558d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ blake3 = "1.8.2" run-on-drop = "1.0.0" egui = { version = "0.34.1", default-features = false } egui_tiles = { version = "0.15.0", default-features = false } +numeric-sort = "0.1.5" [build-dependencies] repc = "0.1.1" diff --git a/src/tree/output.rs b/src/tree/output.rs index 79b70dc2..78b65c4f 100644 --- a/src/tree/output.rs +++ b/src/tree/output.rs @@ -69,6 +69,7 @@ use { }, ahash::AHashMap, jay_config::video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode}, + numeric_sort::cmp, smallvec::SmallVec, std::{ cell::{Cell, RefCell}, @@ -730,7 +731,7 @@ impl OutputNode { pub fn find_workspace_insertion_point(&self, name: &str) -> Option>> { if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted { for existing_ws in self.workspaces.iter() { - if name < existing_ws.name.as_str() { + if cmp(name, &existing_ws.name) == std::cmp::Ordering::Less { return Some(existing_ws); } } @@ -1133,7 +1134,7 @@ impl OutputNode { pub fn handle_workspace_display_order_update(self: &Rc) { if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted { let mut workspaces: Vec<_> = self.workspaces.iter().collect(); - workspaces.sort_by(|a, b| a.name.cmp(&b.name)); + workspaces.sort_by(|a, b| cmp(&a.name, &b.name)); for ws_ref in workspaces { ws_ref.detach(); self.workspaces.add_last_existing(&ws_ref); diff --git a/toml-spec/spec/spec.generated.md b/toml-spec/spec/spec.generated.md index 5267e49d..55aa4668 100644 --- a/toml-spec/spec/spec.generated.md +++ b/toml-spec/spec/spec.generated.md @@ -5609,7 +5609,7 @@ The string should have one of the following values: - `sorted`: - Workspaces are sorted alphabetically and cannot be manually dragged. + Workspaces are sorted using natural ordering and cannot be manually dragged. diff --git a/toml-spec/spec/spec.yaml b/toml-spec/spec/spec.yaml index ce380a82..c863177d 100644 --- a/toml-spec/spec/spec.yaml +++ b/toml-spec/spec/spec.yaml @@ -4533,7 +4533,7 @@ WorkspaceDisplayOrder: - value: manual description: Workspaces are not sorted and can be manually dragged. - value: sorted - description: Workspaces are sorted alphabetically and cannot be manually dragged. + description: Workspaces are sorted using natural ordering and cannot be manually dragged. BlendSpace: From ca939f13a607d6e7305f5121c842e3fd53964e38 Mon Sep 17 00:00:00 2001 From: llyyr Date: Mon, 30 Mar 2026 20:38:27 +0530 Subject: [PATCH 2/2] docs: update books for workspace dispaly order sorting algorithm change --- book/src/configuration/theme.md | 2 +- book/src/workspaces.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/book/src/configuration/theme.md b/book/src/configuration/theme.md index fcbd543a..e142d379 100644 --- a/book/src/configuration/theme.md +++ b/book/src/configuration/theme.md @@ -198,7 +198,7 @@ appear in the bar: : Workspaces can be reordered by dragging (default) `sorted` -: Workspaces are displayed in alphabetical order +: Workspaces are displayed using natural ordering. ```toml workspace-display-order = "sorted" diff --git a/book/src/workspaces.md b/book/src/workspaces.md index 324f292f..100e13b7 100644 --- a/book/src/workspaces.md +++ b/book/src/workspaces.md @@ -99,8 +99,8 @@ modes: - **manual** (default) -- workspaces appear in the order they were created and can be reordered by dragging their titles in the bar. -- **sorted** -- workspaces are sorted alphabetically. Dragging to reorder is - disabled. +- **sorted** -- workspaces are sorted using natural ordering. Dragging to + reorder is disabled. Set the order in your configuration: