|
4 | 4 | try: |
5 | 5 | # check if argcomplete is installed |
6 | 6 | import argcomplete |
7 | | -except ImportError: |
| 7 | +except ImportError: # pragma: no cover |
8 | 8 | # not installed, skip the rest of the file |
9 | 9 | pass |
10 | 10 |
|
@@ -70,7 +70,7 @@ def tokens_for_completion(line, endidx): |
70 | 70 | break |
71 | 71 | except ValueError: |
72 | 72 | # ValueError can be caused by missing closing quote |
73 | | - if not quotes_to_try: |
| 73 | + if not quotes_to_try: # pragma: no cover |
74 | 74 | # Since we have no more quotes to try, something else |
75 | 75 | # is causing the parsing error. Return None since |
76 | 76 | # this means the line is malformed. |
@@ -228,15 +228,14 @@ def __call__(self, argument_parser, completer=None, always_complete_options=True |
228 | 228 | output_stream.write(ifs.join(completions).encode(argcomplete.sys_encoding)) |
229 | 229 | elif outstr: |
230 | 230 | # if there are no completions, but we got something from stdout, try to print help |
231 | | - |
232 | 231 | # trick the bash completion into thinking there are 2 completions that are unlikely |
233 | 232 | # to ever match. |
234 | | - outstr = outstr.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ').strip() |
235 | | - # generate a filler entry that should always sort first |
236 | | - filler = ' {0:><{width}}'.format('', width=len(outstr)/2) |
237 | | - outstr = ifs.join([filler, outstr]) |
238 | 233 |
|
239 | | - output_stream.write(outstr.encode(argcomplete.sys_encoding)) |
| 234 | + comp_type = int(os.environ["COMP_TYPE"]) |
| 235 | + if comp_type == 63: # type is 63 for second tab press |
| 236 | + print(outstr.rstrip(), file=argcomplete.debug_stream, end='') |
| 237 | + |
| 238 | + output_stream.write(ifs.join([ifs, ' ']).encode(argcomplete.sys_encoding)) |
240 | 239 | else: |
241 | 240 | # if completions is None we assume we don't know how to handle it so let bash |
242 | 241 | # go forward with normal filesystem completion |
|
0 commit comments