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:
parent
b37638dda4
commit
f808539dea
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
1
test/regression/3270-crash-in-autocomplete/cmd
Normal file
1
test/regression/3270-crash-in-autocomplete/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cvery<c-x><c-w><c-n>()<c-o>
|
1
test/regression/3270-crash-in-autocomplete/in
Normal file
1
test/regression/3270-crash-in-autocomplete/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
test(bool very_long_variable_name) : very_long_variable_name(%(replace))
|
2
test/regression/3270-crash-in-autocomplete/out
Normal file
2
test/regression/3270-crash-in-autocomplete/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
test(bool very_long_variable_name) :
|
||||||
|
very_long_variable_name(very_long_variable_name())
|
2
test/regression/3270-crash-in-autocomplete/rc
Normal file
2
test/regression/3270-crash-in-autocomplete/rc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
source "%val{runtime}/rc/tools/autowrap.kak"
|
||||||
|
autowrap-enable
|
Loading…
Reference in New Issue
Block a user