forked from qt-creator/qt-creator
Editor: Fix code folding marker visibility
... after split in new window. Fixes: QTCREATORBUG-27748 Change-Id: Idc6270e3bbc39a5c1e679357ba0fbd840e5312c7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -646,6 +646,8 @@ public:
|
|||||||
void updateSyntaxInfoBar(const Highlighter::Definitions &definitions, const QString &fileName);
|
void updateSyntaxInfoBar(const Highlighter::Definitions &definitions, const QString &fileName);
|
||||||
void removeSyntaxInfoBar();
|
void removeSyntaxInfoBar();
|
||||||
void configureGenericHighlighter(const KSyntaxHighlighting::Definition &definition);
|
void configureGenericHighlighter(const KSyntaxHighlighting::Definition &definition);
|
||||||
|
void setupFromDefinition(const KSyntaxHighlighting::Definition &definition);
|
||||||
|
KSyntaxHighlighting::Definition currentDefinition();
|
||||||
void rememberCurrentSyntaxDefinition();
|
void rememberCurrentSyntaxDefinition();
|
||||||
void openLinkUnderCursor(bool openInNextSplit);
|
void openLinkUnderCursor(bool openInNextSplit);
|
||||||
|
|
||||||
@@ -1216,7 +1218,7 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
|||||||
connect(m_document->document(), &QTextDocument::modificationChanged,
|
connect(m_document->document(), &QTextDocument::modificationChanged,
|
||||||
q, &TextEditorWidget::updateTextLineEndingLabel);
|
q, &TextEditorWidget::updateTextLineEndingLabel);
|
||||||
q->updateTextLineEndingLabel();
|
q->updateTextLineEndingLabel();
|
||||||
|
setupFromDefinition(currentDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorWidget::~TextEditorWidget()
|
TextEditorWidget::~TextEditorWidget()
|
||||||
@@ -3293,10 +3295,7 @@ void TextEditorWidgetPrivate::configureGenericHighlighter(
|
|||||||
|
|
||||||
if (definition.isValid()) {
|
if (definition.isValid()) {
|
||||||
highlighter->setDefinition(definition);
|
highlighter->setDefinition(definition);
|
||||||
m_commentDefinition.singleLine = definition.singleLineCommentMarker();
|
setupFromDefinition(definition);
|
||||||
m_commentDefinition.multiLineStart = definition.multiLineCommentMarker().first;
|
|
||||||
m_commentDefinition.multiLineEnd = definition.multiLineCommentMarker().second;
|
|
||||||
q->setCodeFoldingSupported(true);
|
|
||||||
} else {
|
} else {
|
||||||
q->setCodeFoldingSupported(false);
|
q->setCodeFoldingSupported(false);
|
||||||
}
|
}
|
||||||
@@ -3304,12 +3303,26 @@ void TextEditorWidgetPrivate::configureGenericHighlighter(
|
|||||||
m_document->setFontSettings(TextEditorSettings::fontSettings());
|
m_document->setFontSettings(TextEditorSettings::fontSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidgetPrivate::setupFromDefinition(const KSyntaxHighlighting::Definition &definition)
|
||||||
|
{
|
||||||
|
if (!definition.isValid())
|
||||||
|
return;
|
||||||
|
m_commentDefinition.singleLine = definition.singleLineCommentMarker();
|
||||||
|
m_commentDefinition.multiLineStart = definition.multiLineCommentMarker().first;
|
||||||
|
m_commentDefinition.multiLineEnd = definition.multiLineCommentMarker().second;
|
||||||
|
q->setCodeFoldingSupported(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
KSyntaxHighlighting::Definition TextEditorWidgetPrivate::currentDefinition()
|
||||||
|
{
|
||||||
|
if (auto highlighter = qobject_cast<Highlighter *>(m_document->syntaxHighlighter()))
|
||||||
|
return highlighter->definition();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditorWidgetPrivate::rememberCurrentSyntaxDefinition()
|
void TextEditorWidgetPrivate::rememberCurrentSyntaxDefinition()
|
||||||
{
|
{
|
||||||
auto highlighter = qobject_cast<Highlighter *>(m_document->syntaxHighlighter());
|
const Highlighter::Definition &definition = currentDefinition();
|
||||||
if (!highlighter)
|
|
||||||
return;
|
|
||||||
const Highlighter::Definition &definition = highlighter->definition();
|
|
||||||
if (definition.isValid())
|
if (definition.isValid())
|
||||||
Highlighter::rememberDefinitionForDocument(definition, m_document.data());
|
Highlighter::rememberDefinitionForDocument(definition, m_document.data());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user