-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-133363: Fix Cmd completion for lines beginning with !
#133364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,6 +289,31 @@ def do_tab_completion_test(self, args): | |
| self.assertIn(b'ab_completion_test', output) | ||
| self.assertIn(b'tab completion success', output) | ||
|
|
||
| def test_bang_completion_without_do_shell(self): | ||
| script = textwrap.dedent(""" | ||
| import cmd | ||
| class simplecmd(cmd.Cmd): | ||
| def completedefault(self, text, line, begidx, endidx): | ||
| return ["hello"] | ||
|
|
||
| def default(self, line): | ||
| if line == "! hello": | ||
| print('tab completion success') | ||
| else: | ||
| print('tab completion failure') | ||
| return True | ||
|
|
||
| simplecmd().cmdloop() | ||
| """) | ||
|
|
||
| # '! h' and complete 'ello' to '! hello' | ||
| input = b"! h\t\n" | ||
|
||
|
|
||
| output = run_pty(script, input) | ||
|
|
||
| self.assertIn(b'ello', output) | ||
|
||
| self.assertIn(b'tab completion success', output) | ||
|
|
||
| def load_tests(loader, tests, pattern): | ||
| tests.addTest(doctest.DocTestSuite()) | ||
| return tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The :class:`cmd.Cmd` class has been fixed to call the ``completedefault`` | ||
| method whenever the ``do_shell`` method is not defined and tab completion is | ||
| requested for a line beginning with ``!``. Previously ``completedefault`` | ||
| was called only if there were no spaces between the ``!`` and the cursor | ||
|
||
| position where tab completion was attempted. | ||
Uh oh!
There was an error while loading. Please reload this page.