mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-24 18:36:18 +04:00
Merge 7e001b98d0
into dc941d6d24
This commit is contained in:
commit
c8598e15d4
@ -510,6 +510,7 @@ pub fn doc(&self) -> &str {
|
||||
wclose, "Close window",
|
||||
wonly, "Close windows except current",
|
||||
select_register, "Select register",
|
||||
copy_between_registers, "Copy contents of selected register to another",
|
||||
insert_register, "Insert register",
|
||||
align_view_middle, "Align view middle",
|
||||
align_view_top, "Align view top",
|
||||
@ -5357,6 +5358,24 @@ fn select_register(cx: &mut Context) {
|
||||
})
|
||||
}
|
||||
|
||||
fn copy_between_registers(cx: &mut Context) {
|
||||
// Copy from selected register to the register of the next keypress
|
||||
let Some(values) = cx.editor.registers.read(cx.register.unwrap_or('"'), cx.editor) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let values: Vec<String> = values.map(|value| value.to_string()).collect();
|
||||
|
||||
cx.on_next_key(move |cx, event| {
|
||||
if let Some(ch) = event.char() {
|
||||
if let Err(err) = cx.editor.registers.write(ch, values) {
|
||||
cx.editor.set_error(err.to_string());
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn insert_register(cx: &mut Context) {
|
||||
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
|
||||
cx.on_next_key(move |cx, event| {
|
||||
|
Loading…
Reference in New Issue
Block a user