Bug 8370 - tab completing input to squashed short options is unreliable
Summary: tab completing input to squashed short options is unreliable
Status: NEW
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Misc (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: MediumPrio
Assignee: Bugzilla mail exporter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-19 14:45 CEST by Tobias
Modified: 2024-07-12 11:02 CEST (History)
1 user (show)

See Also:
Acceptance Criteria:


Attachments
Disable completion for unidentified options (825 bytes, patch)
2024-06-20 09:42 CEST, Tobias
Details
Allow one option completer from squashed short options (2.92 KB, patch)
2024-06-20 13:28 CEST, Tobias
Details

Description Tobias cendio 2024-06-19 14:45:59 CEST
For instance, tab completing
> $ tl-config -Ra
should call the completer for flag -a.

It won't find the option completer though since it's trying to identify an option name corresponding to the squashed short options--in this case 'Ra'.

Consequently it moves forward with the default completer. In this particular tl-config case this results in completions from the parameter completer which may produce unviable input to the --all-entries option.
Comment 1 Tobias cendio 2024-06-19 14:47:13 CEST
Note that tab completing the following works fine:
> $ tl-config -R -a
Comment 2 Tobias cendio 2024-06-19 14:49:30 CEST
Seen with server build #3632 on RHEL9.
Comment 3 Tobias cendio 2024-06-20 09:42:57 CEST
Created attachment 1203 [details]
Disable completion for unidentified options

This could be solved simply by disabling completion when we detect previous word is an option but we cannot identify a matching option. Might not be too unreasonable since in general it's unambiguous what option to complete for.

Attaching a patch suggestion for optcomplete.py which after some quick testing seems to be working as intended.
Comment 4 Tobias cendio 2024-06-20 13:28:22 CEST
Created attachment 1204 [details]
Allow one option completer from squashed short options

Note that the patch suggestion in comment #3 would disable the default completer following two squashed boolean short options, which is not expected completion behavior.

Attaching a second patch suggestion here which, starting from a series of squashed short options, would proceed with one option completer if all other short options take no arguments.

Did some quick testing with tab completing "$ tl-config -Ra" and it seems to be working.
Comment 5 Samuel Mannehed cendio 2024-06-25 13:27:24 CEST
Our optionparser has logic for splitting combined shortopts. Perhaps we can plug in to that when solving this?

Note You need to log in before you can comment on or make changes to this bug.