Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(man): avoid duplicated man page and dir completions #787

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

scop
Copy link
Owner

@scop scop commented Aug 20, 2022

If a directory with the same name as an already found man page candidate from manpath is present, they both end up in completions as a duplicate with the trailing slash included.

To work around, skip file based completion altogether when a man page from manpath is among found candidates. A workaround for the workaround, i.e. "forcing" file based completion, is to prefix the argument with a ./.

Closes #420

If a directory with the same name as an already found man page candidate
from manpath is present, they both end up in completions as a duplicate
with the trailing slash included.

To work around, skip file based completion altogether when a man page
from manpath is among found candidates. A workaround for the workaround,
i.e. "forcing" file based completion, is to prefix the argument with a
`./`.

Closes #420
@scop
Copy link
Owner Author

scop commented Aug 20, 2022

Draft: I'm not sure I'm happy with this. Let's discuss in #420.

@@ -99,12 +99,12 @@ _man()
fi

# shellcheck disable=SC2053
if [[ $prev != $mansect ]]; then
# File based completion for the rest, prepending ./ if needed
if [[ $prev != $mansect && -z ${COMPREPLY-} ]]; then
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could instead loop through the completions found before start below and check and remove duplicates from file based ones, but that'd be very slow when there are lots of man page completions from man path (e.g. man <TAB> gives 9000+ on the system I'm looking at).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

man xyz stays xy if directory with same name present
1 participant