forked from espressif/esp-idf
fix(autocomplete): handle @-argument autocompletion in bash
Enable @-argument completion only if '@' is not present in COMP_WORDBREAKS. When '@' is included, the @-argument is not considered part of the completion word, causing @-argument completion to function unreliably in bash. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -126,6 +126,7 @@ class BashShell(UnixShell):
|
||||
then
|
||||
echo "$WARNING_MSG"
|
||||
fi
|
||||
export IDF_PY_COMP_WORDBREAKS="$COMP_WORDBREAKS"
|
||||
fi
|
||||
""")
|
||||
|
||||
|
@@ -454,7 +454,13 @@ def init_cli(verbose_output: Optional[List]=None) -> Any:
|
||||
return None
|
||||
|
||||
def shell_complete(self, ctx: click.core.Context, incomplete: str) -> List[CompletionItem]:
|
||||
if incomplete.startswith('@'):
|
||||
# Enable @-argument completion in bash only if @ is not present in
|
||||
# COMP_WORDBREAKS. When @ is included, the @-argument is not considered
|
||||
# part of the completion word, causing @-argument completion to function
|
||||
# unreliably in bash.
|
||||
complete_file = ('bash' not in os.environ.get('_IDF.PY_COMPLETE', '') or
|
||||
'@' not in os.environ.get('IDF_PY_COMP_WORDBREAKS', ''))
|
||||
if incomplete.startswith('@') and complete_file:
|
||||
path_prefix = incomplete[1:]
|
||||
candidates = glob.glob(path_prefix + '*')
|
||||
result = [CompletionItem(f'@{c}') for c in candidates]
|
||||
|
Reference in New Issue
Block a user