Update inserted range when generating InsertCompletionHide hook param

The buffer might have been mutated in the mean time.

Fixes #3270
This commit is contained in:
Maxime Coste 2020-01-08 20:25:27 +11:00
parent b37638dda4
commit f808539dea
6 changed files with 12 additions and 1 deletions

View File

@ -81,7 +81,7 @@ void update_backward(ConstArrayView<Buffer::Change> changes, RangeContainer& ran
} }
template<typename RangeContainer> template<typename RangeContainer>
void update_ranges(Buffer& buffer, size_t& timestamp, RangeContainer& ranges) void update_ranges(Buffer& buffer, size_t& timestamp, RangeContainer&& ranges)
{ {
if (timestamp == buffer.timestamp()) if (timestamp == buffer.timestamp())
return; return;

View File

@ -464,6 +464,9 @@ void InsertCompleter::update(bool allow_implicit)
setup_ifn(); setup_ifn();
} }
auto& get_first(InsertCompletion& completions) { return completions.begin; }
auto& get_last(InsertCompletion& completions) { return completions.end; }
void InsertCompleter::reset() void InsertCompleter::reset()
{ {
if (m_explicit_completer or m_completions.is_valid()) if (m_explicit_completer or m_completions.is_valid())
@ -472,6 +475,8 @@ void InsertCompleter::reset()
if (m_context.has_client() and m_current_candidate >= 0 and m_current_candidate < m_completions.candidates.size() - 1) if (m_context.has_client() and m_current_candidate >= 0 and m_current_candidate < m_completions.candidates.size() - 1)
{ {
auto& buffer = m_context.buffer(); auto& buffer = m_context.buffer();
update_ranges(buffer, m_completions.timestamp,
ArrayView<InsertCompletion>(m_completions));
auto ref = buffer.string(m_completions.begin, m_completions.end); auto ref = buffer.string(m_completions.begin, m_completions.end);
const auto& cursor_pos = m_context.selections().main().cursor(); const auto& cursor_pos = m_context.selections().main().cursor();
const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos);

View File

@ -0,0 +1 @@
cvery<c-x><c-w><c-n>()<c-o>

View File

@ -0,0 +1 @@
test(bool very_long_variable_name) : very_long_variable_name(%(replace))

View File

@ -0,0 +1,2 @@
test(bool very_long_variable_name) :
very_long_variable_name(very_long_variable_name())

View File

@ -0,0 +1,2 @@
source "%val{runtime}/rc/tools/autowrap.kak"
autowrap-enable