From afc8ad77e89a1c6c65cd63caeee468273c218314 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 7 Dec 2012 19:17:49 +0100 Subject: [PATCH] InputHandler: tweak prefix completion behaviour --- src/input_handler.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index 9a582467..9f8667f7 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -353,10 +353,10 @@ public: context.ui().menu_show(candidates, menu_pos, MenuStyle::Prompt); bool use_common_prefix = context.options()["complete_prefix"].as_int(); - String prefix = use_common_prefix ? - common_prefix(candidates) - : line.substr(m_completions.start, - m_completions.end - m_completions.start); + String prefix = use_common_prefix ? common_prefix(candidates) : String(); + if (m_completions.end - m_completions.start > prefix.length()) + prefix = line.substr(m_completions.start, + m_completions.end - m_completions.start); auto it = find(candidates, prefix); if (it == candidates.end())