parent
0b37ad4348
commit
7eba55459b
@ -115,12 +115,24 @@ class Completer(QObject):
|
|||||||
parts: The command chunks to get a completion for.
|
parts: The command chunks to get a completion for.
|
||||||
cursor_part: The part the cursor is over currently.
|
cursor_part: The part the cursor is over currently.
|
||||||
"""
|
"""
|
||||||
|
if parts[cursor_part].startswith('-'):
|
||||||
|
# cursor on a flag
|
||||||
|
return
|
||||||
|
filtered_parts = []
|
||||||
|
for i, part in enumerate(parts):
|
||||||
|
if part == '--':
|
||||||
|
break
|
||||||
|
elif part.startswith('-'):
|
||||||
|
if cursor_part >= i:
|
||||||
|
cursor_part -= 1
|
||||||
|
else:
|
||||||
|
filtered_parts.append(part)
|
||||||
if cursor_part == 0:
|
if cursor_part == 0:
|
||||||
# '|' or 'set|'
|
# '|' or 'set|'
|
||||||
return self._models[usertypes.Completion.command]
|
return self._models[usertypes.Completion.command]
|
||||||
# delegate completion to command
|
# delegate completion to command
|
||||||
try:
|
try:
|
||||||
completions = cmdutils.cmd_dict[parts[0]].completion
|
completions = cmdutils.cmd_dict[filtered_parts[0]].completion
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# entering an unknown command
|
# entering an unknown command
|
||||||
return None
|
return None
|
||||||
@ -140,11 +152,11 @@ class Completer(QObject):
|
|||||||
log.completion.debug("completions: {}".format(
|
log.completion.debug("completions: {}".format(
|
||||||
', '.join(dbg_completions)))
|
', '.join(dbg_completions)))
|
||||||
if completion == usertypes.Completion.option:
|
if completion == usertypes.Completion.option:
|
||||||
section = parts[cursor_part - 1]
|
section = filtered_parts[cursor_part - 1]
|
||||||
model = self._models[completion].get(section)
|
model = self._models[completion].get(section)
|
||||||
elif completion == usertypes.Completion.value:
|
elif completion == usertypes.Completion.value:
|
||||||
section = parts[cursor_part - 2]
|
section = filtered_parts[cursor_part - 2]
|
||||||
option = parts[cursor_part - 1]
|
option = filtered_parts[cursor_part - 1]
|
||||||
try:
|
try:
|
||||||
model = self._models[completion][section][option]
|
model = self._models[completion][section][option]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user