Skip to content

Commit 748c675

Browse files
committed
Fix command auto-fill
1 parent 7d155bf commit 748c675

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

sscom_at/plugins/dbg.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,32 @@
4040
_format_frame = None
4141

4242
def _extract_words_from_json(path):
43-
"""Recursively collect dict keys and string leaf values from a JSON file."""
43+
"""Split leaf strings by space into three completion levels:
44+
level-1 (pos 0): 'at'
45+
level-2 (pos 1): 'mmi', 'mode', 'btcfm', ...
46+
level-3 (pos 2+): 'pwron', 'start', 'a2dp', ...
47+
All tokens go into one flat word list for the completer.
48+
"""
4449
try:
4550
with open(path, "r", encoding="utf-8") as f:
4651
data = json.load(f)
4752
except Exception:
4853
return []
49-
words = set()
50-
def _walk(obj):
54+
leaves = []
55+
def _collect(obj):
5156
if isinstance(obj, dict):
52-
for k, v in obj.items():
53-
words.add(str(k))
54-
_walk(v)
57+
for v in obj.values():
58+
_collect(v)
5559
elif isinstance(obj, list):
5660
for item in obj:
57-
_walk(item)
61+
_collect(item)
5862
elif isinstance(obj, str) and obj.strip():
59-
words.add(obj.strip())
60-
_walk(data)
63+
leaves.append(obj.strip())
64+
_collect(data)
65+
words = set()
66+
for cmd in leaves:
67+
for token in cmd.split():
68+
words.add(token)
6169
return sorted(words)
6270

6371

0 commit comments

Comments
 (0)