summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-06-04 10:50:09 +1000
committerMaxime Coste <mawww@kakoune.org>2022-06-04 10:50:09 +1000
commit6ffec7540666702ea3b96a2efa3a32006ff7ad47 (patch)
treefb358cbc42c8fd74a9bd68e3c0223ddd834db262 /src/input_handler.cc
parenta16de52f9cd929c05a0211ac0b19c6fa116bd524 (diff)
Code style cleanups around insert completer
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index d2fb8275..095d85a2 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1345,10 +1345,7 @@ public:
selections.sort_and_merge_overlapping();
}
else if (auto cp = key.codepoint())
- {
- m_completer.try_accept();
insert(*cp);
- }
else if (key == ctrl('r'))
{
on_next_key_with_autoinfo(context(), "register", KeymapMode::None,
@@ -1356,7 +1353,6 @@ public:
auto cp = key.codepoint();
if (not cp or key == Key::Escape)
return;
- m_completer.try_accept();
insert(RegisterManager::instance()[*cp].get(context()));
}, "enter register name", register_doc.str());
update_completions = false;
@@ -1419,7 +1415,6 @@ public:
[this, transient](Key key, Context&) {
if (auto cp = get_raw_codepoint(key))
{
- m_completer.try_accept();
insert(*cp);
context().hooks().run_hook(Hook::InsertKey, key_to_str(key), context());
if (enabled() and not transient)
@@ -1473,6 +1468,7 @@ private:
void insert(ConstArrayView<String> strings)
{
+ m_completer.try_accept();
context().selections().for_each([strings, &buffer=context().buffer()]
(size_t index, Selection& sel) {
Kakoune::insert(buffer, sel, sel.cursor(), strings[std::min(strings.size()-1, index)]);
@@ -1482,10 +1478,7 @@ private:
void insert(Codepoint key)
{
String str{key};
- context().selections().for_each([&buffer=context().buffer(), &str]
- (size_t index, Selection& sel) {
- Kakoune::insert(buffer, sel, sel.cursor(), str);
- });
+ insert(str);
context().hooks().run_hook(Hook::InsertChar, str, context());
}