Skip to content

Commit

Permalink
Strip qotes from string to be tokenized
Browse files Browse the repository at this point in the history
Strip quotes to prevent tokenizer from trying to emit STRING tokens because we want to interpret numbers inside strings. This solves an EOF error trying to double click a line with opening or closing triple quotes as well.
  • Loading branch information
athompson673 authored Oct 25, 2024
1 parent fadcb09 commit 973d3a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spyder/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,12 @@ def mouseDoubleClickEvent(self, event):
pos = block.position()
pos_in_block = cursor.positionInBlock()

# Strip quotes to prevent tokenizer from trying to emit STRING tokens
# because we want to interpret numbers inside strings. This solves
# an EOF error trying to double click a line with opening or closing
# triple quotes as well.
text = text.replace('"', ' ').replace("'", ' ')

for t_type, _, start, end, _ in generate_tokens(StringIO(text).read):
if t_type == NUMBER and start[1] <= pos_in_block <= end[1]:
cursor.setPosition(pos + start[1])
Expand Down

0 comments on commit 973d3a3

Please sign in to comment.