Commit fb46c319 authored by Leandro Melo's avatar Leandro Melo

Plain text editor: Make sure user setting about folding markers is used

It was being reset based on the highlighter definitions.

Consider some refactoring with the related options as well to avoid
overriding user's settings.

Done-with: Thorbjorn Lindeijer
parent 95fea0bf
......@@ -410,7 +410,6 @@ CPPEditor::CPPEditor(QWidget *parent)
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
baseTextDocument()->setSyntaxHighlighter(new CppHighlighter);
m_modelManager = CppTools::CppModelManagerInterface::instance();
......
......@@ -689,7 +689,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
......
......@@ -1807,10 +1807,13 @@ bool BaseTextEditor::lineSeparatorsAllowed() const
return d->m_lineSeparatorsAllowed;
}
void BaseTextEditor::setCodeFoldingVisible(bool b)
void BaseTextEditor::updateCodeFoldingVisible()
{
d->m_codeFoldingVisible = b && d->m_codeFoldingSupported;
slotUpdateExtraAreaWidth();
const bool visible = d->m_codeFoldingSupported && d->m_displaySettings.m_displayFoldingMarkers;
if (d->m_codeFoldingVisible != visible) {
d->m_codeFoldingVisible = visible;
slotUpdateExtraAreaWidth();
}
}
bool BaseTextEditor::codeFoldingVisible() const
......@@ -1827,6 +1830,7 @@ bool BaseTextEditor::codeFoldingVisible() const
void BaseTextEditor::setCodeFoldingSupported(bool b)
{
d->m_codeFoldingSupported = b;
updateCodeFoldingVisible();
}
bool BaseTextEditor::codeFoldingSupported() const
......@@ -5124,7 +5128,6 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
setLineWrapMode(ds.m_textWrapping ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
setLineNumbersVisible(ds.m_displayLineNumbers);
setVisibleWrapColumn(ds.m_showWrapColumn ? ds.m_wrapColumn : 0);
setCodeFoldingVisible(ds.m_displayFoldingMarkers);
setHighlightCurrentLine(ds.m_highlightCurrentLine);
setRevisionsVisible(ds.m_markTextChanges);
setCenterOnScroll(ds.m_centerCursorOnScroll);
......@@ -5147,6 +5150,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
d->m_highlightBlocksInfo = BaseTextEditorPrivateHighlightBlocks();
}
updateCodeFoldingVisible();
updateHighlights();
viewport()->update();
extraArea()->update();
......
......@@ -207,7 +207,7 @@ public:
void setLineSeparatorsAllowed(bool b);
bool lineSeparatorsAllowed() const;
void setCodeFoldingVisible(bool b);
void updateCodeFoldingVisible();
bool codeFoldingVisible() const;
void setCodeFoldingSupported(bool b);
......
......@@ -164,7 +164,6 @@ void PlainTextEditor::configure(const Core::MimeType &mimeType)
baseTextDocument()->setSyntaxHighlighter(highlighter);
setCodeFoldingSupported(false);
setCodeFoldingVisible(false);
if (!mimeType.isNull()) {
m_isMissingSyntaxDefinition = true;
......@@ -189,7 +188,6 @@ void PlainTextEditor::configure(const Core::MimeType &mimeType)
m_commentDefinition.setMultiLineEnd(definition->multiLineCommentEnd());
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
}
} else if (file()) {
const QString &fileName = file()->fileName();
......
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