From 612f48f3cd1cd4f164e7b25b7920e7b4d12da781 Mon Sep 17 00:00:00 2001 From: Rock Boynton Date: Mon, 23 Dec 2024 14:59:46 -0800 Subject: [PATCH] Show the primary selection index on statusline Have the status line show the number of the current selection out of the total in the file. Right now, the `# sels` shows how many selections you have in the current buffer, but this shows the (1-based) index at which which one your primary cursor is on in the current buffer, i.e. `3/6 sels`, then if you press `)`, it would say `4/6` sels etc. This is very helpful when multiple selections are spread out beyond a single view to orient oneself with the current selections. --- book/src/editor.md | 2 +- helix-term/src/ui/statusline.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/book/src/editor.md b/book/src/editor.md index b79792058..c2a7af764 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -138,7 +138,7 @@ The following statusline elements can be configured: | `file-type` | The type of the opened file | | `diagnostics` | The number of warnings and/or errors | | `workspace-diagnostics` | The number of warnings and/or errors on workspace | -| `selections` | The number of active selections | +| `selections` | The primary selection index out of the number of active selections | | `primary-selection-length` | The number of characters currently in primary selection | | `position` | The cursor position | | `position-percentage` | The cursor position as a percentage of the total number of lines | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index adf01bdad..5e3276817 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -347,10 +347,16 @@ fn render_selections(context: &mut RenderContext, write: F) where F: Fn(&mut RenderContext, String, Option