mirror of https://github.com/helix-editor/helix
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.pull/12326/head
parent
e4ef096945
commit
612f48f3cd
|
@ -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 |
|
||||
|
|
|
@ -347,10 +347,16 @@ fn render_selections<F>(context: &mut RenderContext, write: F)
|
|||
where
|
||||
F: Fn(&mut RenderContext, String, Option<Style>) + 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" }),
|
||||
format!(
|
||||
"{}/{} sel{} ",
|
||||
selection.primary_index() + 1,
|
||||
count,
|
||||
if count == 1 { "" } else { "s" }
|
||||
),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue