diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-25 15:18:50 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-06-25 15:18:50 -0400 |
commit | 9f85d0a989039b23b831d18694183ba73ca83266 (patch) | |
tree | a0554a86ca8b255c027cd21ce4d9ed200a44d153 | |
parent | cc118281df23738dbfc41045ca05179255574afb (diff) | |
download | cmd2-git-9f85d0a989039b23b831d18694183ba73ca83266.tar.gz |
Ensure path completion results are sorted alphabetically on all OSes
-rwxr-xr-x | cmd2.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -432,7 +432,7 @@ else: else: xclipproc.stdin.write(txt) xclipproc.stdin.close() - + # but we want it in both the "primary" and "mouse" clipboards xclipproc = subprocess.Popen('xclip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) if six.PY3: @@ -1412,7 +1412,8 @@ class Cmd(cmd.Cmd): elif os.path.isdir(path_completions[0]) and add_sep_after_tilde: completions[0] = os.path.sep + completions[0] - return completions + # If there are multiple completions, then sort them alphabetically + return sorted(completions) # Enable tab completion of paths for relevant commands complete_edit = path_complete @@ -1453,7 +1454,8 @@ class Cmd(cmd.Cmd): if len(exes) == 1 and endidx == len(line): exes[0] += ' ' - return exes + # If there are multiple completions, then sort them alphabetically + return sorted(exes) # noinspection PyUnusedLocal def complete_shell(self, text, line, begidx, endidx): |