From 9521413b62ffeba0020685c5b2a896a1891d5b46 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 3 Nov 2013 11:08:16 +0000 Subject: [PATCH] Tweak insert completion behaviour --- src/client.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.cc b/src/client.cc index 03165a64..b2e5a259 100644 --- a/src/client.cc +++ b/src/client.cc @@ -572,7 +572,7 @@ public: const String& candidate = m_matching_candidates[m_current_candidate]; const auto& cursor_pos = m_context.editor().main_selection().last(); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); - const auto suffix_len = buffer.distance(cursor_pos, m_completions.end); + 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); @@ -774,7 +774,7 @@ public: longest_completion = std::max(longest_completion, it->length()); if (timestamp == buffer.timestamp() and - cursor_pos.line == coord.line and cursor_pos.column <= coord.column and + cursor_pos.line == coord.line and cursor_pos.column >= coord.column and buffer.distance(coord, cursor_pos) < longest_completion) return { coord, end, { opt.begin() + 1, opt.end() }, timestamp }; }