From d0da958f994ee051ba9b60a879dfad45370a95eb Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 10 May 2017 12:05:08 +0200 Subject: [PATCH] Fix whitespace highlighting within python comments and strings Change-Id: Ib3c72483b42c4843efc8deb1c15eddf953c661af Reviewed-by: David Schulz --- src/plugins/pythoneditor/pythonhighlighter.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/pythoneditor/pythonhighlighter.cpp b/src/plugins/pythoneditor/pythonhighlighter.cpp index cd3c489e74a..389beee4b87 100644 --- a/src/plugins/pythoneditor/pythonhighlighter.cpp +++ b/src/plugins/pythoneditor/pythonhighlighter.cpp @@ -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; }