From c1ce1d70146dd4b3cda76adc98bfac90da55d18c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 2 Sep 2024 20:35:07 +1000 Subject: Explicitely call try_accept on InsertCompleter Calling it as part of the insert method was error prone and often led to slightly surprising behaviour, such as the hiding the menu on . --- src/input_handler.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index 85a8fbc1..0693bc43 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1303,15 +1303,19 @@ public: selections.sort_and_merge_overlapping(); } else if (auto cp = key.codepoint()) + { + m_completer.try_accept(); insert(*cp); + } else if (key == ctrl('r')) { + m_completer.try_accept(); on_next_key_with_autoinfo(context(), "register", KeymapMode::None, [this](Key key, Context&) { auto cp = key.codepoint(); if (not cp or key == Key::Escape) return; - insert([&] { return RegisterManager::instance()[*cp].get(context()); }); + insert(RegisterManager::instance()[*cp].get(context())); }, "enter register name", register_doc.str()); update_completions = false; } @@ -1359,6 +1363,7 @@ public: } else if (key == ctrl('v')) { + m_completer.try_accept(); on_next_key_with_autoinfo(context(), "raw-insert", KeymapMode::None, [this, transient](Key key, Context&) { if (auto cp = get_raw_codepoint(key)) @@ -1387,6 +1392,7 @@ public: void paste(StringView content) override { + m_completer.try_accept(); insert(ConstArrayView{content}); m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); } @@ -1424,20 +1430,13 @@ private: template void insert(ConstArrayView strings) { - m_completer.try_accept(); + kak_assert(not m_completer.has_candidate_selected()); 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)]); }, false); } - template - void insert(Func&& lazy_strings) - { - m_completer.try_accept(); - insert(std::forward(lazy_strings)()); - } - void insert(Codepoint key) { String str{key}; -- cgit v1.2.3