[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdevelop/languages/cpp
From: Dominik Haumann <dhdev () gmx ! de>
Date: 2005-03-11 16:53:57
Message-ID: 20050311165357.02B99EED3 () office ! kde ! org
[Download RAW message or body]
CVS commit by dhaumann:
fix bug 60987: auto complete directly if only one available completion
Reviewed by Adam Treat.
BUG: 60987
M +27 -2 cppcodecompletion.cpp 1.163
M +7 -1 cppcodecompletion.h 1.55
M +1 -1 cppsupportpart.cpp 1.290
--- kdevelop/languages/cpp/cppcodecompletion.cpp #1.162:1.163
@@ -860,5 +860,5 @@ QStringList CppCodeCompletion::evaluateE
}
-void CppCodeCompletion::completeText( )
+void CppCodeCompletion::completeText( bool invokedOnDemand /*= false*/ )
{
kdDebug( 9007 ) << "CppCodeCompletion::completeText()" << endl;
@@ -1230,5 +1230,30 @@ void CppCodeCompletion::completeText( )
}
- if ( entryList.size() )
+ QStringList trueMatches;
+
+ if ( invokedOnDemand )
+ {
+ // find matching words
+ QValueList<KTextEditor::CompletionEntry>::Iterator it;
+ for ( it = entryList.begin(); it != entryList.end(); ++it )
+ {
+ if ( (*it).text.startsWith( word :) )
+ {
+ trueMatches << (*it).text;
+
+ // if more than one entry matches, abort immediately
+ if ( trueMatches.size() > 1 )
+ break;
+ }
+ }
+ }
+
+ if ( invokedOnDemand && trueMatches.size() == 1 )
+ {
+ // there is only one entry -> complete immediately
+ m_activeEditor->insertText( m_ccLine, m_ccColumn,
+ trueMatches[0].right( trueMatches[0].length() - word.length() ) );
+ }
+ else if ( entryList.size() )
{
entryList = unique( entryList );
--- kdevelop/languages/cpp/cppcodecompletion.h #1.54:1.55
@@ -74,5 +74,11 @@ public:
public slots:
- void completeText();
+ /**
+ * @param invokedOnDemand if true and there is exactly one matching entry
+ * complete the match immediately without showing the completion box.
+ * This is only true, when the users invokes the completion himself
+ * (eg presses the completion shortcut CTRL+space)
+ */
+ void completeText( bool invokedOnDemand = false );
private slots:
--- kdevelop/languages/cpp/cppsupportpart.cpp #1.289:1.290
@@ -1014,5 +1014,5 @@ void CppSupportPart::slotCompleteText()
if ( !m_pCompletion )
return ;
- m_pCompletion->completeText();
+ m_pCompletion->completeText( true );
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic