Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Lib/idlelib/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def make_pat():


prog = make_pat()
idprog = re.compile(r"\s+(\w+)")
idprog = re.compile(r"\s+([^\\\s([:]+)")
prog_group_name_to_tag = {
"MATCH_SOFTKW": "KEYWORD",
"CASE_SOFTKW": "KEYWORD",
Expand Down Expand Up @@ -346,8 +346,9 @@ def _add_tags_in_section(self, chars, head):
self._add_tag(a, b, head, name)
if matched_text in ("def", "class"):
if m1 := self.idprog.match(chars, b):
a, b = m1.span(1)
self._add_tag(a, b, head, "DEFINITION")
if m1.groups()[0].isidentifier():
a, b = m1.span(1)
self._add_tag(a, b, head, "DEFINITION")

def removecolors(self):
"Remove all colorizing tags."
Expand Down
8 changes: 8 additions & 0 deletions Lib/idlelib/idle_test/test_colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def test_idprog(self):
self.assertIsNone(m)
m = idprog.match(' space')
self.assertEqual(m.group(0), ' space')
m = idprog.match(' space')
self.assertTrue(m.groups()[0].isidentifier())
m = idprog.match(' 42')
self.assertFalse(m.groups()[0].isidentifier())
m = idprog.match(' dot·[T]')
self.assertTrue(m.groups()[0].isidentifier())
m = idprog.match(' cls()')
self.assertTrue(m.groups()[0].isidentifier())


class ColorConfigTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a bug that XID_Continue Unicode characters in function/class names
highlighted incorrectly.
Loading