Fix whitespace highlighting within python comments and strings

Change-Id: Ib3c72483b42c4843efc8deb1c15eddf953c661af
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2017-05-10 12:05:08 +02:00
parent 0a1376dd2c
commit d0da958f99

View File

@@ -131,16 +131,16 @@ int PythonHighlighter::highlightLine(const QString &text, int initialState)
bool hasOnlyWhitespace = true;
while (!(tk = scanner.read()).isEndOfBlock()) {
Format format = tk.format();
if (format == Format_Keyword) {
QString value = scanner.value(tk);
if (isImportKeyword(value) && hasOnlyWhitespace) {
setFormat(tk.begin(), tk.length(), formatForCategory(format));
highlightImport(scanner);
break;
}
if (format == Format_Keyword && isImportKeyword(scanner.value(tk)) && hasOnlyWhitespace) {
setFormat(tk.begin(), tk.length(), formatForCategory(format));
highlightImport(scanner);
} else if (format == Format_Comment
|| format == Format_String
|| format == Format_Doxygen) {
setFormatWithSpaces(text, tk.begin(), tk.length(), formatForCategory(format));
} else {
setFormat(tk.begin(), tk.length(), formatForCategory(format));
}
setFormat(tk.begin(), tk.length(), formatForCategory(format));
if (format != Format_Whitespace)
hasOnlyWhitespace = false;
}