Insert all register values in prompt after <c-r> when Alt-modified

`<c-r><a-.>` will insert all selections joined by space instead of only
the main one as `<c-r>.` would.
This commit is contained in:
Maxime Coste 2022-06-30 16:36:12 +10:00
parent 6565f6edd7
commit d87ee212ba
2 changed files with 10 additions and 3 deletions

View File

@ -798,7 +798,9 @@ The following keys are recognized by this mode to help with editing
select previous completion candidate select previous completion candidate
*<c-r>*:: *<c-r>*::
insert then content of the register given by next key insert then content of the register given by next key, if next key
has the Alt modifier, it will insert all values in the register
joined with spaces, else it will insert the main one
*<c-v>*:: *<c-v>*::
insert next keystroke without interpreting it insert next keystroke without interpreting it

View File

@ -826,11 +826,16 @@ public:
{ {
on_next_key_with_autoinfo(context(), "register", KeymapMode::None, on_next_key_with_autoinfo(context(), "register", KeymapMode::None,
[this](Key key, Context&) { [this](Key key, Context&) {
const bool joined = (bool)(key.modifiers & Key::Modifiers::Alt);
key.modifiers &= ~Key::Modifiers::Alt;
auto cp = key.codepoint(); auto cp = key.codepoint();
if (not cp or key == Key::Escape) if (not cp or key == Key::Escape)
return; return;
StringView reg = context().main_sel_register_value(String{*cp});
m_line_editor.insert(reg); m_line_editor.insert(
joined ? join(RegisterManager::instance()[*cp].get(context()), ' ', false)
: context().main_sel_register_value(String{*cp}));
display(); display();
m_line_changed = true; m_line_changed = true;