From 7619fcb1980ad0db9f73b6d9e1cbd7388cf7a4a5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 17 Nov 2014 13:53:59 +0000 Subject: [PATCH] option completion are valid until a modification is made before it --- src/insert_completer.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/insert_completer.cc b/src/insert_completer.cc index d84e95808..812511d46 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -187,13 +187,17 @@ InsertCompletion complete_option(const Buffer& buffer, ByteCoord cursor_pos, end = buffer.advance(coord, len); } size_t timestamp = (size_t)str_to_int(match[4].str()); + auto changes = buffer.changes_since(timestamp); + if (find_if(changes, [&](const Buffer::Change& change){ + return change.begin < coord; + }) != changes.end()) + return {}; ByteCount longest_completion = 0; for (auto it = opt.begin() + 1; it != opt.end(); ++it) 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 + if (cursor_pos.line == coord.line and cursor_pos.column >= coord.column and buffer.distance(coord, cursor_pos) < longest_completion) { ComplAndDescList res;