Coloring white spaces even if there's no highlight syntax definition set.

Relative to QTCREATORBUG-1225.
This commit is contained in:
Leandro Melo
2010-06-15 10:35:39 +02:00
parent 54ea41af47
commit 0894033f93
3 changed files with 50 additions and 45 deletions

View File

@@ -160,32 +160,31 @@ void PlainTextEditor::fileChanged()
void PlainTextEditor::configure(const Core::MimeType &mimeType)
{
Highlighter *highlighter = new Highlighter();
baseTextDocument()->setSyntaxHighlighter(highlighter);
m_isMissingSyntaxDefinition = true;
if (mimeType.isNull())
return;
QString definitionId;
if (!mimeType.isNull()) {
const QString &type = mimeType.type();
setMimeType(type);
const QString &type = mimeType.type();
setMimeType(type);
QString definitionId = Manager::instance()->definitionIdByMimeType(type);
if (definitionId.isEmpty())
definitionId = findDefinitionId(mimeType, true);
definitionId = Manager::instance()->definitionIdByMimeType(type);
if (definitionId.isEmpty())
definitionId = findDefinitionId(mimeType, true);
}
if (!definitionId.isEmpty()) {
const QSharedPointer<HighlightDefinition> &definition =
Manager::instance()->definition(definitionId);
if (!definition.isNull()) {
Highlighter *highlighter = new Highlighter(definition->initialContext());
baseTextDocument()->setSyntaxHighlighter(highlighter);
highlighter->setDefaultContext(definition->initialContext());
m_commentDefinition.setAfterWhiteSpaces(definition->isCommentAfterWhiteSpaces());
m_commentDefinition.setSingleLine(definition->singleLineComment());
m_commentDefinition.setMultiLineStart(definition->multiLineCommentStart());
m_commentDefinition.setMultiLineEnd(definition->multiLineCommentEnd());
setFontSettings(TextEditorSettings::instance()->fontSettings());
m_isMissingSyntaxDefinition = false;
}
} else if (file()) {
@@ -194,6 +193,8 @@ void PlainTextEditor::configure(const Core::MimeType &mimeType)
m_isMissingSyntaxDefinition = false;
}
setFontSettings(TextEditorSettings::instance()->fontSettings());
// @todo: Indentation specification through the definition files is not really being used
// because Kate recommends to configure indentation through another feature. Maybe we should
// provide something similar in Creator? For now, only normal indentation is supported.