# HG changeset patch # User Rock Boynton # Date 1747313582 -7200 # Node ID 44b81c8fb513a9b8958f73802b0e9eb74151f5ae # Parent 32d8f329f44cd2a5ab2e31eb6402681c46863614 Show the primary selection index on statusline (#12326) Co-authored-by: Rock Boynton Co-authored-by: Michael Davis diff -r 32d8f329f44c -r 44b81c8fb513 book/src/editor.md --- a/book/src/editor.md Thu May 15 08:24:33 2025 -0400 +++ b/book/src/editor.md Thu May 15 14:53:02 2025 +0200 @@ -138,7 +138,7 @@ | `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 -r 32d8f329f44c -r 44b81c8fb513 helix-term/src/ui/statusline.rs --- a/helix-term/src/ui/statusline.rs Thu May 15 08:24:33 2025 -0400 +++ b/helix-term/src/ui/statusline.rs Thu May 15 14:53:02 2025 +0200 @@ -332,10 +332,15 @@ where F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy, { - let count = context.doc.selection(context.view.id).len(); + let selection = context.doc.selection(context.view.id); + let count = selection.len(); write( context, - format!(" {} sel{} ", count, if count == 1 { "" } else { "s" }).into(), + if count == 1 { + " 1 sel ".into() + } else { + format!(" {}/{count} sels ", selection.primary_index() + 1).into() + }, ); }