Wordbreak issue when completing before end of line
See original GitHub issuerepro.py
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
import argparse
import argcomplete
parser = argparse.ArgumentParser()
parser.add_argument('--pass', choices=('name_one', 'name_two'))
parser.add_argument('--fail', choices=('name:one', 'name:two'))
parser.add_argument('--other')
argcomplete.autocomplete(parser)
The following completion in the middle of the line results in faulty completion:
$ ./repro.py --fail name:<TAB> --other
It becomes this:
$ ./repro.py --fail name:name: --other
Instead I’d expect to need to double-tab for this output:
$ ./repro.py --fail name:<TAB><TAB> --other
one two
For comparison, it works fine at the end of the line:
$ ./repro.py --fail name:<TAB><TAB>
one two
If an underscore is used instead of a colon, it works in the middle of the line or at the end:
$ ./repro.py --pass name_<TAB><TAB>
name_one name_two
$ ./repro.py --pass name_<TAB><TAB> --other
name_one name_two
This appears to be due to the lexer clearing last_wordbreak_pos
here: https://github.com/kislyuk/argcomplete/blob/5a20d6165fbb4d4d58559378919b05964870cc16/argcomplete/my_shlex.py#L296-L297
Commenting out those two lines resolved the issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
wrap, overflow - wrap - , and - word - break - LogRocket Blog
Force line breaks are caused by explicit line-breaking controls or line breaks marking the end or start of blocks of text.
Read more >How to prevent my words breaking on to a new line
1) Go to the “Page Layout” tab on the Ribbon · 2) Look for the “Page Setup” group · 3) Click on “Hyphenation”...
Read more >word-break - CSS-Tricks
The word-break property in CSS can be used to change when line breaks ought to occur. Normally, line breaks in text can only...
Read more >How to fix words splitting at the end of lines? - YouTube
Sometimes, words are seen splitting at the end of lines. This happens if the original document was written in a system with an...
Read more >310. Why does my text wrap to the next line before reaching ...
Ensure that Indentation, both before and after text, are set to zero and that no special formatting has been set.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
great point @evanunderscore, let’s leave that behavior as is.
Thanks for confirming @evanunderscore. I’ve been thinking about this and while I think we should proceed with #352 in the short term, I also hope we can enable a future where arguments after the cursor can affect parser state. This can be useful with mutually exclusive arguments, etc.
I’ll merge #352 and then try to scope out a design for what would be necessary to enable that, in a separate PR/issue.