X Tutup
Skip to content

Commit 6d7fa19

Browse files
committed
Verify completion mode
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 9fa5f8d commit 6d7fa19

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bpython/autocomplete.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
SUBSTRING = 'substring'
4949
FUZZY = 'fuzzy'
5050

51+
ALL_MODES = (SIMPLE, SUBSTRING, FUZZY)
52+
5153
MAGIC_METHODS = ["__%s__" % s for s in [
5254
"init", "repr", "str", "lt", "le", "eq", "ne", "gt", "ge", "cmp", "hash",
5355
"nonzero", "unicode", "getattr", "setattr", "get", "set","call", "len",

bpython/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from bpython.keys import cli_key_dispatch as key_dispatch
77
from bpython.autocomplete import SIMPLE as default_completion
88

9+
import bpython.autocomplete
10+
911
class Struct(object):
1012
"""Simple class for instantiating objects we can add arbitrary attributes
1113
to and use for various arbitrary things."""
@@ -229,8 +231,13 @@ def get_key_no_doublebind(attr, already_used={}):
229231
for key in (struct.pastebin_key, struct.save_key):
230232
key_dispatch[key]
231233

234+
# expand path of history file
232235
struct.hist_file = os.path.expanduser(struct.hist_file)
233236

237+
# verify completion mode
238+
if struct.autocomplete_mode not in bpython.autocomplete.ALL_MODES:
239+
struct.autocomplete_mode = default_completion
240+
234241
def load_theme(struct, path, colors, default_colors):
235242
theme = ConfigParser()
236243
with open(path, 'r') as f:

0 commit comments

Comments
 (0)
X Tutup