forked from qt-creator/qt-creator
TextEditor: update matching parenthesis in the editor
... after updating the parenthesis in the layout Task-number: QTCREATORBUG-26183 Change-Id: I346046fbc3932b94227c1ac5bee6b0d7c44651e1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -387,12 +387,12 @@ TextDocumentLayout::~TextDocumentLayout()
|
||||
|
||||
void TextDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
|
||||
{
|
||||
if (parentheses.isEmpty()) {
|
||||
if (TextBlockUserData *userData = textUserData(block))
|
||||
userData->clearParentheses();
|
||||
} else {
|
||||
userData(block)->setParentheses(parentheses);
|
||||
}
|
||||
if (TextDocumentLayout::parentheses(block) == parentheses)
|
||||
return;
|
||||
|
||||
userData(block)->setParentheses(parentheses);
|
||||
if (auto layout = qobject_cast<TextDocumentLayout *>(block.document()->documentLayout()))
|
||||
emit layout->parenthesesChanged(block);
|
||||
}
|
||||
|
||||
Parentheses TextDocumentLayout::parentheses(const QTextBlock &block)
|
||||
@@ -684,4 +684,18 @@ void TextDocumentLayout::FoldValidator::finalize()
|
||||
}
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const Parenthesis &parenthesis)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug << (parenthesis.type == Parenthesis::Opened ? "Opening " : "Closing ") << parenthesis.chr
|
||||
<< " at " << parenthesis.pos;
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
bool Parenthesis::operator==(const Parenthesis &other) const
|
||||
{
|
||||
return pos == other.pos && chr == other.chr && source == other.source && type == other.type;
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
Reference in New Issue
Block a user