Skip to content

Commit 5377f66

Browse files
committed
fix: only the buildin words
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 6c70847 commit 5377f66

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

Lib/_pyrepl/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ def gen_colors_from_token_stream(
196196
is_def_name = False
197197
span = Span.from_token(token, line_lengths)
198198
yield ColorSpan(span, "definition")
199-
elif (keyword.iskeyword(token.string)
200-
and not (prev_token and prev_token.type == T.OP and prev_token.string == ".")):
199+
elif keyword.iskeyword(token.string):
201200
span = Span.from_token(token, line_lengths)
202201
yield ColorSpan(span, "keyword")
203202
if token.string in IDENTIFIERS_AFTER:

Lib/test/test_pyrepl/test_utils.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ def gen_raise():
6363

6464
def test_gen_colors_keyword_highlighting(self):
6565
no_highlight_cases = [
66-
("a.set", [(".", "op")]), # 'set' should not be highlighted after '.'
67-
("a.def", [(".", "op")]), # 'def' should not be highlighted after '.'
68-
("obj.class", [(".", "op")]), # 'class' should not be highlighted after '.'
69-
("obj.list", [(".", "op")]), # 'list' should not be highlighted after '.'
70-
("obj.match", [(".", "op")]), # 'match' should not be highlighted after '.'
66+
("a.set", [(".", "op")]),
67+
("obj.list", [(".", "op")]),
68+
("obj.match", [(".", "op")]),
7169
]
7270
for code, expected_highlights in no_highlight_cases:
7371
with self.subTest(code=code):
@@ -82,8 +80,6 @@ def test_gen_colors_keyword_highlighting(self):
8280
highlight_cases = [
8381
("set", [("set", "builtin")]),
8482
("list", [("list", "builtin")]),
85-
("def func():", [("def", "keyword"), ("func", "definition"), ("(", "op"), (")", "op"), (":", "op")]),
86-
("class A:", [("class", "keyword"), ("A", "definition"), (":", "op")]),
8783
]
8884
for code, expected_highlights in highlight_cases:
8985
with self.subTest(code=code):

0 commit comments

Comments
 (0)