Skip to content

Commit fe53097

Browse files
fix dict completion problem
1 parent 2bd4a10 commit fe53097

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

bpython/line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ def current_word(cursor_offset, line):
2323

2424
def current_dict_key(cursor_offset, line):
2525
"""If in dictionary completion, return the current key"""
26-
matches = list(re.finditer(r'[\w_][\w0-9._]*\[([\w0-9._(), ]*)', line))
26+
matches = list(re.finditer(r'''[\w_][\w0-9._]*\[([\w0-9._(), '"]*)''', line))
2727
for m in matches:
2828
if m.start(1) <= cursor_offset and m.end(1) >= cursor_offset:
2929
return (m.start(1), m.end(1), m.group(1))
3030
return None
3131

3232
def current_dict(cursor_offset, line):
3333
"""If in dictionary completion, return the dict that should be used"""
34-
matches = list(re.finditer(r'([\w_][\w0-9._]*)\[([\w0-9._(), ]*)', line))
34+
matches = list(re.finditer(r'''([\w_][\w0-9._]*)\[([\w0-9._(), '"]*)''', line))
3535
for m in matches:
3636
if m.start(2) <= cursor_offset and m.end(2) >= cursor_offset:
3737
return (m.start(1), m.end(1), m.group(1))

bpython/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def update(self, cursor_offset, current_line, matches, completer):
336336
assert matches is not None
337337
self.matches = matches
338338
self.completer = completer
339-
assert self.completer.locate(self.orig_cursor_offset, self.orig_line) is not None, (self.completer.locate, self.orig_cursor_offset, self.orig_line)
339+
#assert self.completer.locate(self.orig_cursor_offset, self.orig_line) is not None, (self.completer.locate, self.orig_cursor_offset, self.orig_line)
340340
self.index = -1
341341
self.start, self.end, self.current_word = self.completer.locate(self.orig_cursor_offset, self.orig_line)
342342

bpython/test/test_line_properties.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_simple(self):
133133
self.assertAccess('asdf[<(1, >|]')
134134
self.assertAccess('asdf[<(1, 2)>|]')
135135
#TODO self.assertAccess('d[d[<12|>')
136+
self.assertAccess("d[<'a>|")
136137

137138
class TestCurrentDict(LineTestCase):
138139
def setUp(self):

0 commit comments

Comments
 (0)