Commit 17579bb9 authored by mae's avatar mae
Browse files

Make completion box hide on an editor undo operation

parent 1699ec54
...@@ -532,12 +532,20 @@ ITextMarkable *BaseTextEditor::markableInterface() const ...@@ -532,12 +532,20 @@ ITextMarkable *BaseTextEditor::markableInterface() const
return baseTextDocument()->documentMarker(); return baseTextDocument()->documentMarker();
} }
void BaseTextEditor::maybeEmitTextChangedBecauseOfUndo()
{
if (document()->isRedoAvailable())
emit d->m_editable->contentsChangedBecauseOfUndo();
}
ITextEditable *BaseTextEditor::editableInterface() const ITextEditable *BaseTextEditor::editableInterface() const
{ {
if (!d->m_editable) { if (!d->m_editable) {
d->m_editable = const_cast<BaseTextEditor*>(this)->createEditableInterface(); d->m_editable = const_cast<BaseTextEditor*>(this)->createEditableInterface();
connect(this, SIGNAL(textChanged()), connect(this, SIGNAL(textChanged()),
d->m_editable, SIGNAL(contentsChanged())); d->m_editable, SIGNAL(contentsChanged()));
connect(this, SIGNAL(textChanged()),
this, SLOT(maybeEmitTextChangedBecauseOfUndo()));
connect(this, SIGNAL(changed()), connect(this, SIGNAL(changed()),
d->m_editable, SIGNAL(changed())); d->m_editable, SIGNAL(changed()));
} }
...@@ -696,15 +704,17 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch ...@@ -696,15 +704,17 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch
if (d->m_animator) if (d->m_animator)
d->m_animator->finish(); d->m_animator->finish();
d->m_contentsChanged = true; d->m_contentsChanged = true;
QTextDocument *doc = document();
// Keep the line numbers and the block information for the text marks updated // Keep the line numbers and the block information for the text marks updated
if (charsRemoved != 0) { if (charsRemoved != 0) {
d->updateMarksLineNumber(); d->updateMarksLineNumber();
d->updateMarksBlock(document()->findBlock(position)); d->updateMarksBlock(document()->findBlock(position));
} else { } else {
const QTextBlock posBlock = document()->findBlock(position); const QTextBlock posBlock = doc->findBlock(position);
const QTextBlock nextBlock = document()->findBlock(position + charsAdded); const QTextBlock nextBlock = doc->findBlock(position + charsAdded);
if (posBlock != nextBlock) { if (posBlock != nextBlock) {
d->updateMarksLineNumber(); d->updateMarksLineNumber();
d->updateMarksBlock(posBlock); d->updateMarksBlock(posBlock);
...@@ -713,6 +723,9 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch ...@@ -713,6 +723,9 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch
d->updateMarksBlock(posBlock); d->updateMarksBlock(posBlock);
} }
} }
if (doc->isRedoAvailable())
emit d->m_editable->contentsChangedBecauseOfUndo();
} }
......
...@@ -459,6 +459,7 @@ private slots: ...@@ -459,6 +459,7 @@ private slots:
void highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags); void highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags);
void setFindScope(const QTextCursor &); void setFindScope(const QTextCursor &);
void currentEditorChanged(Core::IEditor *editor); void currentEditorChanged(Core::IEditor *editor);
void maybeEmitTextChangedBecauseOfUndo();
private: private:
Internal::BaseTextEditorPrivate *d; Internal::BaseTextEditorPrivate *d;
......
...@@ -134,6 +134,8 @@ CompletionWidget::CompletionWidget(CompletionSupport *support, ITextEditable *ed ...@@ -134,6 +134,8 @@ CompletionWidget::CompletionWidget(CompletionSupport *support, ITextEditable *ed
this, SIGNAL(completionListClosed())); this, SIGNAL(completionListClosed()));
connect(m_completionListView, SIGNAL(activated(QModelIndex)), connect(m_completionListView, SIGNAL(activated(QModelIndex)),
SLOT(closeList(QModelIndex))); SLOT(closeList(QModelIndex)));
connect(editor, SIGNAL(contentsChangedBecauseOfUndo()),
this, SLOT(closeList()));
} }
CompletionWidget::~CompletionWidget() CompletionWidget::~CompletionWidget()
......
...@@ -124,6 +124,7 @@ public: ...@@ -124,6 +124,7 @@ public:
signals: signals:
void contentsChanged(); void contentsChanged();
void contentsChangedBecauseOfUndo();
void markRequested(TextEditor::ITextEditor *editor, int line); void markRequested(TextEditor::ITextEditor *editor, int line);
void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu); void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu);
void tooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position); void tooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position);
......
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