gh-102130: Support tab completion in cmd for Libedit. (GH-107748)

---

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Constantin Hong 2023-12-05 16:24:56 +09:00 committed by GitHub
parent dc824c5dc1
commit aa5bee30ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 1 deletions

View file

@ -108,7 +108,15 @@ class Cmd:
import readline
self.old_completer = readline.get_completer()
readline.set_completer(self.complete)
readline.parse_and_bind(self.completekey+": complete")
if readline.backend == "editline":
if self.completekey == 'tab':
# libedit uses "^I" instead of "tab"
command_string = "bind ^I rl_complete"
else:
command_string = f"bind {self.completekey} rl_complete"
else:
command_string = f"{self.completekey}: complete"
readline.parse_and_bind(command_string)
except ImportError:
pass
try: