From ff2e0db6c284740daf15c01dcb8e253e63c8cd5c Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Mon, 25 Feb 2008 02:09:39 +0000 Subject: [PATCH] * fix longest prefix algorithm for sorted models: commonPrefix(...) returns the length, not the prefix. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23217 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiCompleter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index cc27d33e20..2246888268 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -695,11 +695,12 @@ docstring GuiCompleter::longestUniqueCompletion() const QString const & mids = model.data(model.index(mid, 0), Qt::EditRole).toString(); - int sn = s.length(); - s = commonPrefix(mids, s); + size_t oldLen = s.length(); + size_t len = commonPrefix(mids, s); + s = s.left(len); // left or right? - if (s.length() == sn) { + if (oldLen == len) { // middle is not far enough i = mid + 1; } else {