Commit 5088f07f authored by Takumi ASAKI's avatar Takumi ASAKI Committed by David Schulz

TextEditor: Fix code completion and pasting in snippets.

Fixes case 2 and 3 of QTCREATORBUG-14633.

Task-number: QTCREATORBUG-14633
Change-Id: I19bf3c81c26f8a89a508591b0e7264251e0e6254
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 9c8eeacc
......@@ -135,12 +135,14 @@ bool AssistProposalItem::prematurelyApplies(const QChar &c) const
void AssistProposalItem::apply(TextEditorWidget *editorWidget, int basePosition) const
{
if (data().canConvert<QString>())
if (data().canConvert<QString>()) {
applySnippet(editorWidget, basePosition);
else if (data().canConvert<QuickFixOperation::Ptr>())
} else if (data().canConvert<QuickFixOperation::Ptr>()) {
applyQuickFix(editorWidget, basePosition);
else
} else {
applyContextualContent(editorWidget, basePosition);
editorWidget->encourageApply();
}
}
void AssistProposalItem::applyContextualContent(TextEditorWidget *editorWidget, int basePosition) const
......
......@@ -6349,6 +6349,13 @@ void TextEditorWidget::unCommentSelection()
Utils::unCommentSelection(this, d->m_commentDefinition);
}
void TextEditorWidget::encourageApply()
{
if (!d->m_snippetOverlay->isVisible() || d->m_snippetOverlay->isEmpty())
return;
d->m_snippetOverlay->updateEquivalentSelections(textCursor());
}
void TextEditorWidget::showEvent(QShowEvent* e)
{
triggerPendingUpdates();
......@@ -6584,6 +6591,7 @@ void TextEditorWidget::copy()
void TextEditorWidget::paste()
{
QPlainTextEdit::paste();
encourageApply();
}
void TextEditorWidgetPrivate::collectToCircularClipboard()
......
......@@ -363,6 +363,8 @@ public:
virtual void rewrapParagraph();
virtual void unCommentSelection();
virtual void encourageApply();
public slots: // Qt4-style connect used in EditorConfiguration
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
virtual void setMarginSettings(const TextEditor::MarginSettings &);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment