Skip to content

Commit 3f20d8e

Browse files
dict key matching regex no longer matches beyond the end of a key
1 parent eb321aa commit 3f20d8e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bpython/line.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def current_word(cursor_offset: int, line: str) -> Optional[LinePart]:
3434
return LinePart(start, end, word)
3535

3636

37-
_current_dict_key_re = LazyReCompile(r"""[\w_][\w0-9._]*\[(.*)""")
37+
_current_dict_key_re = LazyReCompile(
38+
r"""[\w_][\w0-9._]*\[('[^']*|"[^"]*|[\w0-9._(), '"]*)"""
39+
)
3840

3941

4042
def current_dict_key(cursor_offset: int, line: str) -> Optional[LinePart]:
@@ -45,7 +47,9 @@ def current_dict_key(cursor_offset: int, line: str) -> Optional[LinePart]:
4547
return None
4648

4749

48-
_current_dict_re = LazyReCompile(r"""([\w_][\w0-9._]*)\[(.*)""")
50+
_current_dict_re = LazyReCompile(
51+
r"""([\w_][\w0-9._]*)\[('[^']*|"[^"]*|[\w0-9._(), '"]*)"""
52+
)
4953

5054

5155
def current_dict(cursor_offset: int, line: str) -> Optional[LinePart]:

0 commit comments

Comments
 (0)