mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-01 16:32:54 +03:00
Use a struct rather than a std::pair for InputHandler::Insertion
This commit is contained in:
parent
7a59a6d758
commit
9d50dd3886
@ -899,8 +899,8 @@ public:
|
||||
if (m_disable_hooks)
|
||||
context().user_hooks_support().disable();
|
||||
|
||||
last_insert().first = mode;
|
||||
last_insert().second.clear();
|
||||
last_insert().mode = mode;
|
||||
last_insert().keys.clear();
|
||||
context().hooks().run_hook("InsertBegin", "", context());
|
||||
prepare(m_insert_mode);
|
||||
}
|
||||
@ -932,7 +932,7 @@ public:
|
||||
void on_key(Key key, KeepAlive keep_alive) override
|
||||
{
|
||||
auto& buffer = context().buffer();
|
||||
last_insert().second.push_back(key);
|
||||
last_insert().keys.push_back(key);
|
||||
if (m_mode == Mode::InsertReg)
|
||||
{
|
||||
if (key.modifiers == Key::Modifiers::None)
|
||||
@ -1032,14 +1032,14 @@ public:
|
||||
insert('\t');
|
||||
else if (key == ctrl('n'))
|
||||
{
|
||||
last_insert().second.pop_back();
|
||||
m_completer.select(1, last_insert().second);
|
||||
last_insert().keys.pop_back();
|
||||
m_completer.select(1, last_insert().keys);
|
||||
update_completions = false;
|
||||
}
|
||||
else if (key == ctrl('p'))
|
||||
{
|
||||
last_insert().second.pop_back();
|
||||
m_completer.select(-1, last_insert().second);
|
||||
last_insert().keys.pop_back();
|
||||
m_completer.select(-1, last_insert().keys);
|
||||
update_completions = false;
|
||||
}
|
||||
else if (key == ctrl('x'))
|
||||
@ -1230,14 +1230,14 @@ void InputHandler::insert(InsertMode mode)
|
||||
|
||||
void InputHandler::repeat_last_insert()
|
||||
{
|
||||
if (m_last_insert.second.empty())
|
||||
if (m_last_insert.keys.empty())
|
||||
return;
|
||||
|
||||
Vector<Key> keys;
|
||||
swap(keys, m_last_insert.second);
|
||||
swap(keys, m_last_insert.keys);
|
||||
// context.last_insert will be refilled by the new Insert
|
||||
// this is very inefficient.
|
||||
push_mode(new InputModes::Insert(*this, m_last_insert.first));
|
||||
push_mode(new InputModes::Insert(*this, m_last_insert.mode));
|
||||
for (auto& key : keys)
|
||||
current_mode().handle_key(key);
|
||||
kak_assert(dynamic_cast<InputModes::Normal*>(¤t_mode()) != nullptr);
|
||||
|
@ -93,7 +93,7 @@ private:
|
||||
void push_mode(InputMode* new_mode);
|
||||
std::unique_ptr<InputMode> pop_mode(InputMode* current_mode);
|
||||
|
||||
using Insertion = std::pair<InsertMode, Vector<Key>>;
|
||||
struct Insertion{ InsertMode mode; Vector<Key> keys; };
|
||||
Insertion m_last_insert = {InsertMode::Insert, {}};
|
||||
|
||||
char m_recording_reg = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user