Skip to content

Commit 3a64844

Browse files
authored
gh-136801: Fix PyREPL syntax highlightning on match cases after multi-line case (GH-136804)
1 parent 6a1c93a commit 3a64844

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Lib/_pyrepl/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
241241
return s in keyword_first_sets_match
242242
return True
243243
case (
244-
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
244+
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
245245
TI(string="case"),
246246
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
247247
| TI(T.OP, string="(" | "*" | "-" | "[" | "{")
248248
):
249249
return True
250250
case (
251-
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
251+
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
252252
TI(string="case"),
253253
TI(T.NAME, string=s)
254254
):

Lib/test/test_pyrepl/test_reader.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def funct(case: str = sys.platform) -> None:
375375
)
376376
match case:
377377
case "emscripten": print("on the web")
378-
case "ios" | "android": print("on the phone")
378+
case "ios" | "android":
379+
print("on the phone")
379380
case _: print('arms around', match.group(1))
380381
"""
381382
)
@@ -393,7 +394,8 @@ def funct(case: str = sys.platform) -> None:
393394
{o}){z}
394395
{K}match{z} case{o}:{z}
395396
{K}case{z} {s}"emscripten"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the web"{z}{o}){z}
396-
{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}
397+
{K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
398+
{b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
397399
{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}
398400
"""
399401
)
@@ -402,14 +404,14 @@ def funct(case: str = sys.platform) -> None:
402404
reader, _ = handle_all_events(events)
403405
self.assert_screen_equal(reader, code, clean=True)
404406
self.assert_screen_equal(reader, expected_sync)
405-
self.assertEqual(reader.pos, 2**7 + 2**8)
406-
self.assertEqual(reader.cxy, (0, 14))
407+
self.assertEqual(reader.pos, 396)
408+
self.assertEqual(reader.cxy, (0, 15))
407409

408410
async_msg = "{k}async{z} ".format(**colors)
409411
expected_async = expected.format(a=async_msg, **colors)
410412
more_events = itertools.chain(
411413
code_to_events(code),
412-
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 13,
414+
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 14,
413415
code_to_events("async "),
414416
)
415417
reader, _ = handle_all_events(more_events)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix PyREPL syntax highlightning on match cases after multi-line case. Contributed by Olga Matoula.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy