summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-01-08 20:25:27 +1100
committerMaxime Coste <mawww@kakoune.org>2020-01-08 20:33:26 +1100
commitf808539deaf14b1810e8578ffa2d88a35dc12a46 (patch)
tree1df4d229ad920e97f29954c9fb25af0925ec6208 /src
parentb37638dda4531efd5953ec12a0331bcb0876ada3 (diff)
Update inserted range when generating InsertCompletionHide hook param
The buffer might have been mutated in the mean time. Fixes #3270
Diffstat (limited to 'src')
-rw-r--r--src/changes.hh2
-rw-r--r--src/insert_completer.cc5
2 files changed, 6 insertions, 1 deletions
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<Buffer::Change> changes, RangeContainer& ran
}
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())
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<InsertCompletion>(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);