Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Lib/_pyrepl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
return s in keyword_first_sets_match
return True
case (
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
TI(string="case"),
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
| TI(T.OP, string="(" | "*" | "-" | "[" | "{")
):
return True
case (
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
TI(string="case"),
TI(T.NAME, string=s)
):
Expand Down
12 changes: 7 additions & 5 deletions Lib/test/test_pyrepl/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ def funct(case: str = sys.platform) -> None:
)
match case:
case "emscripten": print("on the web")
case "ios" | "android": print("on the phone")
case "ios" | "android":
print("on the phone")
case _: print('arms around', match.group(1))
"""
)
Expand All @@ -393,7 +394,8 @@ def funct(case: str = sys.platform) -> None:
{o}){z}
{K}match{z} case{o}:{z}
{K}case{z} {s}"emscripten"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the web"{z}{o}){z}
{K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
{K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
{b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
{K}case{z} {K}_{z}{o}:{z} {b}print{z}{o}({z}{s}'arms around'{z}{o},{z} match{o}.{z}group{o}({z}{n}1{z}{o}){z}{o}){z}
"""
)
Expand All @@ -402,14 +404,14 @@ def funct(case: str = sys.platform) -> None:
reader, _ = handle_all_events(events)
self.assert_screen_equal(reader, code, clean=True)
self.assert_screen_equal(reader, expected_sync)
self.assertEqual(reader.pos, 2**7 + 2**8)
self.assertEqual(reader.cxy, (0, 14))
self.assertEqual(reader.pos, 396)
self.assertEqual(reader.cxy, (0, 15))

async_msg = "{k}async{z} ".format(**colors)
expected_async = expected.format(a=async_msg, **colors)
more_events = itertools.chain(
code_to_events(code),
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 13,
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 14,
code_to_events("async "),
)
reader, _ = handle_all_events(more_events)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix PyREPL syntax highlightning on match cases after multi-line case. Contributed by Olga Matoula.
Loading