From bf98b38afd5338f6be617cfaf4bb251eb011e2b0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 14 May 2014 00:59:36 +0100 Subject: Use a plain SelectionList for Context, remove DynamicSelectionList --- src/insert_completer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/insert_completer.cc') diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 7b7d52fe..def3b951 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -185,13 +185,14 @@ void InsertCompleter::select(int offset) if (m_current_candidate < 0) m_current_candidate += m_matching_candidates.size(); const String& candidate = m_matching_candidates[m_current_candidate]; - const auto& cursor_pos = m_context.selections().main().cursor(); + auto& selections = m_context.selections(); + const auto& cursor_pos = selections.main().cursor(); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); const auto suffix_len = std::max(0_byte, buffer.distance(cursor_pos, m_completions.end)); const auto buffer_len = buffer.byte_count(); auto ref = buffer.string(m_completions.begin, m_completions.end); - for (auto& sel : m_context.selections()) + for (auto& sel : selections) { auto offset = buffer.offset(sel.cursor()); auto pos = buffer.iterator_at(sel.cursor()); @@ -200,6 +201,7 @@ void InsertCompleter::select(int offset) { pos = buffer.erase(pos - prefix_len, pos + suffix_len); buffer.insert(pos, candidate); + const_cast(selections).update(); } } m_completions.end = cursor_pos; -- cgit v1.2.3