Skip to content

Commit f157a91

Browse files
rockboyntonRock Boyntonthe-mikedavis
authored
Show the primary selection index on statusline (#12326)
Co-authored-by: Rock Boynton <[email protected]> Co-authored-by: Michael Davis <[email protected]>
1 parent a7c3a43 commit f157a91

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

book/src/editor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ The following statusline elements can be configured:
138138
| `file-type` | The type of the opened file |
139139
| `diagnostics` | The number of warnings and/or errors |
140140
| `workspace-diagnostics` | The number of warnings and/or errors on workspace |
141-
| `selections` | The number of active selections |
141+
| `selections` | The primary selection index out of the number of active selections |
142142
| `primary-selection-length` | The number of characters currently in primary selection |
143143
| `position` | The cursor position |
144144
| `position-percentage` | The cursor position as a percentage of the total number of lines |

helix-term/src/ui/statusline.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,15 @@ fn render_selections<'a, F>(context: &mut RenderContext<'a>, write: F)
332332
where
333333
F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy,
334334
{
335-
let count = context.doc.selection(context.view.id).len();
335+
let selection = context.doc.selection(context.view.id);
336+
let count = selection.len();
336337
write(
337338
context,
338-
format!(" {} sel{} ", count, if count == 1 { "" } else { "s" }).into(),
339+
if count == 1 {
340+
" 1 sel ".into()
341+
} else {
342+
format!(" {}/{count} sels ", selection.primary_index() + 1).into()
343+
},
339344
);
340345
}
341346

0 commit comments

Comments
 (0)