Skip to content

Commit e0da129

Browse files
committed
Use custom titles for register select info boxes
Previously all register selection info boxes had "Registers" as the title. That was particularly confusing for `copy_between_registers` which presents two info boxes back-to-back.
1 parent b8912ad commit e0da129

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

helix-term/src/commands.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5544,7 +5544,10 @@ fn wonly(cx: &mut Context) {
55445544
}
55455545

55465546
fn select_register(cx: &mut Context) {
5547-
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
5547+
cx.editor.autoinfo = Some(Info::from_registers(
5548+
"Select register",
5549+
&cx.editor.registers,
5550+
));
55485551
cx.on_next_key(move |cx, event| {
55495552
cx.editor.autoinfo = None;
55505553
if let Some(ch) = event.char() {
@@ -5554,7 +5557,10 @@ fn select_register(cx: &mut Context) {
55545557
}
55555558

55565559
fn insert_register(cx: &mut Context) {
5557-
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
5560+
cx.editor.autoinfo = Some(Info::from_registers(
5561+
"Insert register",
5562+
&cx.editor.registers,
5563+
));
55585564
cx.on_next_key(move |cx, event| {
55595565
cx.editor.autoinfo = None;
55605566
if let Some(ch) = event.char() {
@@ -5571,7 +5577,10 @@ fn insert_register(cx: &mut Context) {
55715577
}
55725578

55735579
fn copy_between_registers(cx: &mut Context) {
5574-
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
5580+
cx.editor.autoinfo = Some(Info::from_registers(
5581+
"Copy from register",
5582+
&cx.editor.registers,
5583+
));
55755584
cx.on_next_key(move |cx, event| {
55765585
cx.editor.autoinfo = None;
55775586

@@ -5585,7 +5594,10 @@ fn copy_between_registers(cx: &mut Context) {
55855594
};
55865595
let values: Vec<_> = values.map(|value| value.to_string()).collect();
55875596

5588-
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
5597+
cx.editor.autoinfo = Some(Info::from_registers(
5598+
"Copy into register",
5599+
&cx.editor.registers,
5600+
));
55895601
cx.on_next_key(move |cx, event| {
55905602
cx.editor.autoinfo = None;
55915603

helix-view/src/info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ impl Info {
5757
}
5858
}
5959

60-
pub fn from_registers(registers: &Registers) -> Self {
60+
pub fn from_registers(title: impl Into<Cow<'static, str>>, registers: &Registers) -> Self {
6161
let body: Vec<_> = registers
6262
.iter_preview()
6363
.map(|(ch, preview)| (ch.to_string(), preview))
6464
.collect();
6565

66-
let mut infobox = Self::new("Registers", &body);
66+
let mut infobox = Self::new(title, &body);
6767
infobox.width = 30; // copied content could be very long
6868
infobox
6969
}

0 commit comments

Comments
 (0)