From c93d7e265db5c8f88cc8a35a5f75971ba9577611 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 10 Oct 2017 16:40:54 +0200 Subject: [PATCH] PromptWidget::getCompletionPrefix refactored --- src/debugger/gui/PromptWidget.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 348381307..5920f98be 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -913,22 +913,23 @@ bool PromptWidget::saveBuffer(const FilesystemNode& file) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string PromptWidget::getCompletionPrefix(const StringList& completions) { - // Find the largest match at the beginning of the completions provided + // Find the number of characters matching for each of the completions provided for(uInt32 len = 1;; len++) { - for(const auto& s1 : completions) + for(uInt32 i = 0; i < completions.size(); i++) { + string s1 = completions[i]; if(s1.length() < len) { return s1.substr(0, len - 1); } string find = s1.substr(0, len); - for(const auto& s2 : completions) + + for(uInt32 j = i + 1; j < completions.size(); j++) { - if(!BSPF::matches(s2, find)) - { + string s2 = completions[j]; + if(!BSPF::startsWithIgnoreCase(s2, find)) return s1.substr(0, len - 1); - } } } }