Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionLib/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -273,7 +273,7 @@ def complete(self, text, state):
endidx = readline.get_endidx() - stripped
if begidx>0:
cmd, args, foo = self.parseline(line)
ifcmd == '':
ifnot cmd:
compfunc = self.completedefault
else:
try:
Expand Down
24 changes: 24 additions & 0 deletionsLib/test/test_cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -289,6 +289,30 @@ 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.replace(" ", "") == "!hello":
print('tab completion success')
else:
print('tab completion failure')
return True

simplecmd().cmdloop()
""")

# '! h' or '!h' and complete 'ello' to 'hello'
for input in [b"! h\t\n", b"!h\t\n"]:
with self.subTest(input=input):
output = run_pty(script, input)
self.assertIn(b'hello', output)
self.assertIn(b'tab completion success', output)

def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite())
return tests
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
The :class:`cmd.Cmd` class has been fixed to reliably call the ``completedefault``
method whenever the ``do_shell`` method is not defined and tab completion is
requested for a line beginning with ``!``.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp