bash-completion icon indicating copy to clipboard operation
bash-completion copied to clipboard

mutt: do not lose the + in mutt -f +foo<tab>

Open mgedmin opened this issue 3 years ago • 5 comments

Closes #464.

mgedmin avatar Nov 11 '20 18:11 mgedmin

I am baffled: I have a machine with Ubuntu 18.04 LTS (bash 4.4.20(1)-release, bash-completion 1:2.8-1ubuntu1) where mutt -f =<tab> eats the = and where a similar fix would be needed. On my other machine with Ubuntu 20.10 (bash 5.0.17(1)-release, bash-completion 1:2.11-2ubuntu1) mutt -f =<tab> works fine and only mutt -f +<tab> needs to restore the +.

mgedmin avatar Nov 11 '20 19:11 mgedmin

I've found a solution that works on both Ubuntu 18.04 and 20.10, but I don't entirely understand the situation: https://github.com/mgedmin/dotfiles/commit/4758e78e2ea8e57636873d79e796691eff237ed2

Update: I've incorporated that solution into this PR. The more I think about it, the more it seems right: it should adjust to changes in $COMP_WORDBREAKS automatically. (Although COMP_WORDBREAKS is not the reason completion behaves differently on Ubuntu 18.04 and 20.10. I wonder if there was a bash bug that got fixed)

mgedmin avatar Nov 11 '20 19:11 mgedmin

Welp this doesn't actually work on Ubuntu 20.10. I thought I'd tested it! Back to the drawing board...

mgedmin avatar Nov 12 '20 08:11 mgedmin

Welp this doesn't actually work on Ubuntu 20.10. I thought I'd tested it!

I did test it, and mutt -f =fold<tab> is correctly expanded to mutt -f =folder.

What breaks is mutt -f =<tab> instead of showing all possible mailboxes it expands to mutt -f =\=.

Fixed now.

mgedmin avatar Nov 12 '20 09:11 mgedmin

I now have tests for this in #467. Without this fix they fail as follows:

____________________________________ TestMutt.test_plus_is_not_eaten ____________________________________

self = <test_mutt.TestMutt object at 0x7fa06943ff10>, completion = <CompletionResult ['\x08\x08foo.mbx']>

    @pytest.mark.complete("mutt -F muttrc -f +f", require_cmd=True, cwd="mutt")
    def test_plus_is_not_eaten(self, completion):
>       assert completion == "oo.mbx".split()
E       AssertionError: assert <CompletionRe...\x08foo.mbx']> == ['oo.mbx']
E         Use -v to get the full diff

/home/mg/src/bash-completion/test/t/test_mutt.py:30: AssertionError

mgedmin avatar Nov 12 '20 09:11 mgedmin