Skip to content

Commit 26a5f4d

Browse files
committed
Added better check for whether a path is a directory
1 parent ea5c242 commit 26a5f4d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,10 +1600,11 @@ def path_complete(self, text, line, begidx, endidx, dir_exe_only=False, dir_only
16001600
:return: List[str] - a list of possible tab completions
16011601
"""
16021602

1603-
# Used to complete ~ and ~user strings with a list of users that have existing home dirs
1603+
# Used to complete ~ and ~user strings
16041604
def complete_users():
16051605

1606-
# We are returning ~user strings that resolve to directories, so don't append a space or quote
1606+
# We are returning ~user strings that resolve to directories,
1607+
# so don't append a space or quote in the case of a single result.
16071608
self.allow_appended_space = False
16081609
self.allow_closing_quote = False
16091610

@@ -1692,7 +1693,7 @@ def complete_users():
16921693
matches = [c for c in matches if os.path.isdir(c)]
16931694

16941695
# Don't append a space or closing quote to directory
1695-
if len(matches) == 1 and not os.path.isfile(matches[0]):
1696+
if len(matches) == 1 and os.path.isdir(matches[0]):
16961697
self.allow_appended_space = False
16971698
self.allow_closing_quote = False
16981699

0 commit comments

Comments
 (0)