From: Leandro Melo Date: Fri, 20 May 2011 10:29:40 +0000 (+0200) Subject: Completion: Ignore non identifiers when matching proposals X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1c60ae10399d3e194b6b0a30abd12c96279fbce3;p=qt-creator-jp%2Fqt-creator-jp.git Completion: Ignore non identifiers when matching proposals Since now we reduced the idle editor time for showing completions, some things started to be a bit annoying. This fix changes the prefix from the proposal to include only letters, digits, and the underscore. Yes, technically they are not allways identifiers in a generic sense, but it should be enough for our purpose. Now, you should not receive a proposal 'foo:' when you have already typed 'foo' in QML, for example. Change-Id: Ica92182a34636598faedb067d0527e37ca6fee89 Reviewed-on: http://codereview.qt.nokia.com/46 Reviewed-by: Roberto Raggi --- diff --git a/src/plugins/texteditor/codeassist/basicproposalitemlistmodel.cpp b/src/plugins/texteditor/codeassist/basicproposalitemlistmodel.cpp index ae34da69f6..76a752896a 100644 --- a/src/plugins/texteditor/codeassist/basicproposalitemlistmodel.cpp +++ b/src/plugins/texteditor/codeassist/basicproposalitemlistmodel.cpp @@ -241,6 +241,14 @@ QString BasicProposalItemListModel::proposalPrefix() const // Compute common prefix QString firstKey = m_currentItems.first()->text(); + int ignore = 0; + for (int i = firstKey.length() - 1; i >= 0; --i, ++ignore) { + const QChar &c = firstKey.at(i); + if (c.isLetterOrNumber() || c == QLatin1Char('_')) + break; + } + if (ignore) + firstKey.chop(ignore); QString lastKey = m_currentItems.last()->text(); const int length = qMin(firstKey.length(), lastKey.length()); firstKey.truncate(length);