diff --git a/src/changes.hh b/src/changes.hh index 638a4bcb..5b64cbec 100644 --- a/src/changes.hh +++ b/src/changes.hh @@ -81,7 +81,7 @@ void update_backward(ConstArrayView changes, RangeContainer& ran } template -void update_ranges(Buffer& buffer, size_t& timestamp, RangeContainer& ranges) +void update_ranges(Buffer& buffer, size_t& timestamp, RangeContainer&& ranges) { if (timestamp == buffer.timestamp()) return; diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 57a12478..e7818524 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -464,6 +464,9 @@ void InsertCompleter::update(bool allow_implicit) setup_ifn(); } +auto& get_first(InsertCompletion& completions) { return completions.begin; } +auto& get_last(InsertCompletion& completions) { return completions.end; } + void InsertCompleter::reset() { 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) { auto& buffer = m_context.buffer(); + update_ranges(buffer, m_completions.timestamp, + ArrayView(m_completions)); auto ref = buffer.string(m_completions.begin, m_completions.end); const auto& cursor_pos = m_context.selections().main().cursor(); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); diff --git a/test/regression/3270-crash-in-autocomplete/cmd b/test/regression/3270-crash-in-autocomplete/cmd new file mode 100644 index 00000000..30087534 --- /dev/null +++ b/test/regression/3270-crash-in-autocomplete/cmd @@ -0,0 +1 @@ +cvery() diff --git a/test/regression/3270-crash-in-autocomplete/in b/test/regression/3270-crash-in-autocomplete/in new file mode 100644 index 00000000..75368e84 --- /dev/null +++ b/test/regression/3270-crash-in-autocomplete/in @@ -0,0 +1 @@ +test(bool very_long_variable_name) : very_long_variable_name(%(replace)) diff --git a/test/regression/3270-crash-in-autocomplete/out b/test/regression/3270-crash-in-autocomplete/out new file mode 100644 index 00000000..996d0d80 --- /dev/null +++ b/test/regression/3270-crash-in-autocomplete/out @@ -0,0 +1,2 @@ +test(bool very_long_variable_name) : +very_long_variable_name(very_long_variable_name()) diff --git a/test/regression/3270-crash-in-autocomplete/rc b/test/regression/3270-crash-in-autocomplete/rc new file mode 100644 index 00000000..56ff678f --- /dev/null +++ b/test/regression/3270-crash-in-autocomplete/rc @@ -0,0 +1,2 @@ +source "%val{runtime}/rc/tools/autowrap.kak" +autowrap-enable