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; bool hasOnlyWhitespace = true;
while (!(tk = scanner.read()).isEndOfBlock()) { while (!(tk = scanner.read()).isEndOfBlock()) {
Format format = tk.format(); Format format = tk.format();
if (format == Format_Keyword) { if (format == Format_Keyword && isImportKeyword(scanner.value(tk)) && hasOnlyWhitespace) {
QString value = scanner.value(tk); setFormat(tk.begin(), tk.length(), formatForCategory(format));
if (isImportKeyword(value) && hasOnlyWhitespace) { highlightImport(scanner);
setFormat(tk.begin(), tk.length(), formatForCategory(format)); } else if (format == Format_Comment
highlightImport(scanner); || format == Format_String
break; || 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) if (format != Format_Whitespace)
hasOnlyWhitespace = false; hasOnlyWhitespace = false;
} }