diff --git a/src/syntax/katehighlight.cpp b/src/syntax/katehighlight.cpp --- a/src/syntax/katehighlight.cpp +++ b/src/syntax/katehighlight.cpp @@ -80,10 +80,16 @@ iName = def.name(); iSection = def.translatedSection(); + /** + * get all included definitions, e.g. PHP for HTML highlighting + */ + auto definitions = def.includedDefinitions(); + /** * handle the "no highlighting" case + * it's possible to not have any defintions with malformed file */ - if (!def.isValid()) { + if (!def.isValid() || (definitions.isEmpty() && def.formats().isEmpty())) { // dummy properties + formats m_properties.resize(1); m_propertiesForFormat.push_back(&m_properties[0]); @@ -110,11 +116,6 @@ */ setDefinition(def); - /** - * get all included definitions, e.g. PHP for HTML highlighting - */ - auto definitions = definition().includedDefinitions(); - /** * first: handle only really included definitions */ @@ -251,7 +252,9 @@ { // WE ATM assume ascending offset order Q_ASSERT(m_textLineToHighlight); - Q_ASSERT(format.isValid()); + if (!format.isValid()) { + return; + } // get internal attribute, must exist const auto it = m_formatsIdToIndex.find(format.id());