mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-23 03:21:55 +03:00
Store fake keystrokes when selecting an insert completion candidate
Instead of storing the real 'select next completion' keystroke, generate fake backspace/delete/char keystrokes so that replay of the insert will insert the exact same text. Fixes #135
This commit is contained in:
parent
b5854ece43
commit
3921b234e7
@ -879,12 +879,14 @@ public:
|
||||
insert('\t');
|
||||
else if (key == ctrl('n'))
|
||||
{
|
||||
m_completer.select(1);
|
||||
last_insert().second.pop_back();
|
||||
m_completer.select(1, last_insert().second);
|
||||
update_completions = false;
|
||||
}
|
||||
else if (key == ctrl('p'))
|
||||
{
|
||||
m_completer.select(-1);
|
||||
last_insert().second.pop_back();
|
||||
m_completer.select(-1, last_insert().second);
|
||||
update_completions = false;
|
||||
}
|
||||
else if (key == ctrl('x'))
|
||||
|
@ -245,7 +245,7 @@ InsertCompleter::~InsertCompleter()
|
||||
m_options.unregister_watcher(*this);
|
||||
}
|
||||
|
||||
void InsertCompleter::select(int offset)
|
||||
void InsertCompleter::select(int offset, Vector<Key>& keystrokes)
|
||||
{
|
||||
if (not setup_ifn())
|
||||
return;
|
||||
@ -283,6 +283,13 @@ void InsertCompleter::select(int offset)
|
||||
m_context.ui().info_show(candidate.first, candidate.second, CharCoord{},
|
||||
get_face("Information"), InfoStyle::MenuDoc);
|
||||
}
|
||||
|
||||
for (auto i = 0_byte; i < prefix_len; ++i)
|
||||
keystrokes.push_back(Key::Backspace);
|
||||
for (auto i = 0_byte; i < suffix_len; ++i)
|
||||
keystrokes.push_back(Key::Delete);
|
||||
for (auto& c : candidate.first)
|
||||
keystrokes.push_back(c);
|
||||
}
|
||||
|
||||
void InsertCompleter::update()
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
InsertCompleter& operator=(const InsertCompleter&) = delete;
|
||||
~InsertCompleter();
|
||||
|
||||
void select(int offset);
|
||||
void select(int offset, Vector<Key>& keystrokes);
|
||||
void update();
|
||||
void reset();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user