From a4f5c1d6f54f538f6ed17bcebfa986dae08bb116 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 13 Apr 2016 22:27:31 -0300 Subject: [PATCH] Do not show symbol auto completion when typing: `Constant:` --- editor/RubyCompletionAssist.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/editor/RubyCompletionAssist.cpp b/editor/RubyCompletionAssist.cpp index 3310d03..bb35b24 100644 --- a/editor/RubyCompletionAssist.cpp +++ b/editor/RubyCompletionAssist.cpp @@ -19,7 +19,8 @@ enum KindOfCompletion { MayBeAIdentifier, MayBeAMethod, MayBeConstant, - MayBeASymbol + MayBeASymbol, + MaybeNothing }; static KindOfCompletion kindOfCompletion(QTextDocument *document, int &startPosition) @@ -33,8 +34,12 @@ static KindOfCompletion kindOfCompletion(QTextDocument *document, int &startPosi startPosition++; return MayBeAMethod; } - if (ch == QLatin1Char(':')) + if (ch == QLatin1Char(':')) { + QChar lastChar = document->characterAt(startPosition - 1); + if (lastChar.isLetterOrNumber() || lastChar == QLatin1Char(':')) + return MaybeNothing; return MayBeASymbol; + } if (ch.isUpper()) mayBeAConstant = true; } while (ch.isLetterOrNumber() || ch == QLatin1Char('_')); @@ -143,12 +148,13 @@ TextEditor::IAssistProposal *CompletionAssistProcessor::perform(const TextEditor case MayBeASymbol: addProposalFromSet(proposals, cm->symbolsIn(fileName), myTyping, m_symbolIcon); break; + default: + break; } if (proposals.empty()) { return 0; } - TextEditor::GenericProposalModel *model = new TextEditor::GenericProposalModel; model->loadContent(proposals); TextEditor::IAssistProposal *proposal = new TextEditor::GenericProposal(startPosition, model);