summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2025-02-05 12:55:33 +1100
committerMaxime Coste <mawww@kakoune.org>2025-02-05 12:57:30 +1100
commita6b12ffd1e0c345d4d73462d855c4822b4cf5234 (patch)
tree8878e67f2c4eebf66598131fd8f71026ccf8b7a6 /src/input_handler.cc
parent8b3ddd5df547130b55280debcfc29d5dad7eb9b2 (diff)
Make Control modifier quote inserted registers in prompt mode
It is often usefull to quote the inserted register, like when doing `:grep <c-r>/`, or when pulling selected filenames with `<c-r><a-.>`.
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 0f2c8987..ea803217 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -764,15 +764,17 @@ public:
on_next_key_with_autoinfo(context(), "register", KeymapMode::None,
[this](Key key, Context&) {
const bool joined = (bool)(key.modifiers & Key::Modifiers::Alt);
- key.modifiers &= ~Key::Modifiers::Alt;
+ const bool quoted = (bool)(key.modifiers & Key::Modifiers::Control);
+ key.modifiers &= ~(Key::Modifiers::Alt | Key::Modifiers::Control);
auto cp = key.codepoint();
if (not cp or key == Key::Escape)
return;
+ auto* quoter = Kakoune::quoter(quoted ? Quoting::Kakoune : Quoting::Raw);
m_line_editor.insert(
- joined ? join(RegisterManager::instance()[*cp].get(context()), ' ', false)
- : context().main_sel_register_value(String{*cp}));
+ joined ? join(RegisterManager::instance()[*cp].get(context()) | transform(quoter), ' ', false)
+ : quoter(context().main_sel_register_value(String{*cp})));
display();
m_line_changed = true;