Skip to content

Commit 0f1a018

Browse files
[lldb] Add test to document alias tab completion behaviour (#65760)
While looking at #49528 I found that, happily, aliases can now be tab completed. However, if there is a built-in match that will always be taken. Which is a bit surprising, though logical if we don't want people really messing up their commands I guess. Meaning "b" tab completes to our built-in breakpoint alias, before it looks at any of the aliases. "bf" doesn't match "b", so it looks through the aliases. I didn't find any tests for this in the obvious places, so this adds some.
1 parent 21c251a commit 0f1a018

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lldb/test/API/functionalities/completion/TestCompletion.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,25 @@ def test_command_delete(self):
622622
def test_command_unalias(self):
623623
self.complete_from_to("command unalias ima", "command unalias image")
624624

625+
def test_command_aliases(self):
626+
self.runCmd("command alias brkpt breakpoint")
627+
# If there is an unambiguous completion from the built-in commands,
628+
# we choose that.
629+
self.complete_from_to("br", "breakpoint")
630+
# Only if there is not, do we then look for an unambiguous completion
631+
# from the user defined aliases.
632+
self.complete_from_to("brk", "brkpt")
633+
634+
# Aliases are included when there's no exact match.
635+
self.runCmd("command alias play breakpoint")
636+
self.complete_from_to("pl", ["plugin", "platform", "play"])
637+
638+
# That list can also contain only aliases if there's no built-ins to
639+
# match.
640+
self.runCmd("command alias test_1 breakpoint")
641+
self.runCmd("command alias test_2 breakpoint")
642+
self.complete_from_to("test_", ["test_1", "test_2"])
643+
625644
def test_completion_description_commands(self):
626645
"""Test descriptions of top-level command completions"""
627646
self.check_completion_with_desc(

0 commit comments

Comments
 (0)