You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python editor: syntax highlighting ignores string/comment context ('#' in a string, '"""' in a comment) #660
Describe the bug
The Python editor's syntax highlighting doesn't keep track of where a string or a comment actually starts and ends. Two cases I ran into:
A # inside a string literal is highlighted as if it started a comment — the rest of the line turns the comment color, even though it's still part of the string and normal code.
A """ inside a real comment opens a docstring for the highlighter — every line after the comment is colored as string, for the rest of the file.
The scripts run fine, it just looks wrong and makes the code hard to read.
To Reproduce
Open HAL and load any netlist.
Open the Python Editor.
Type: print("Normal string and after hashtag (#)" + " this part must not be green.")
Everything from the # on is colored as a comment, including the closing quote and the rest of the line.
Type:
# docstrings are crazy """
print("hello")
x = 5
print("hello") and x = 5 are colored as if they were inside a string, and so is everything below them.
Expected behavior
A # inside a string should be colored as part of the string, and only a # outside a string should start a comment. Quotes inside a comment — including """ — should be ignored, and the lines after the comment should keep their normal colors.
Screenshots
Desktop (please complete the following information):
Activity
fix: keep escaped quotes inside highlighted Python strings emsec#660
fix: skip triple quoted strings when looking for a comment emsec#660
fix: skip complete strings when looking for a multi-line string emsec…