summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-05-21 19:21:55 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-05-21 19:21:55 +0200
commitad178e383b98dc3934a084b0307c21bd90b281c7 (patch)
tree372281faf1c6078f958d119c0d7e57dcfbe313e2 /src/input_handler.cc
parenteab12135557cad7431b27afa4cb0cd8051f90fff (diff)
insert mode completion for all selection that matches the main one prefix
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index f36fca9a..dfccdc64 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -596,9 +596,22 @@ public:
if (m_current_candidate < 0)
m_current_candidate += m_matching_candidates.size();
const String& candidate = m_matching_candidates[m_current_candidate];
+ auto main_cursor = m_context.editor().main_selection().last();
+ ByteCount beg_offset = main_cursor - m_completions.begin;
+ ByteCount end_offset = m_completions.end - main_cursor;
+ ByteCount buffer_len = m_context.buffer().byte_count();
+
+ for (auto& sel : m_context.editor().selections())
+ {
+ auto offset = sel.last().offset();
+ if (offset > beg_offset and offset + end_offset < buffer_len and
+ std::equal(sel.last() - beg_offset, sel.last(), m_completions.begin))
+ {
+ m_context.buffer().erase(sel.last() - beg_offset, sel.last() + end_offset);
+ m_context.buffer().insert(sel.last(), candidate);
+ }
+ }
- m_context.buffer().erase(m_completions.begin, m_completions.end);
- m_context.buffer().insert(m_completions.begin, candidate);
m_completions.end = m_completions.begin + candidate.length();
m_completions.timestamp = m_context.buffer().timestamp();
m_context.ui().menu_select(m_current_candidate);