Skip to content

fix: dotfiles excluded from tab completion - #1013

Open
elseawhy wants to merge 1 commit into
HalFrgrd:masterfrom
elseawhy:feature/match-hidden-files
Open

elseawhy wants to merge 1 commit into
HalFrgrd:masterfrom
elseawhy:feature/match-hidden-files

Conversation

@elseawhy

@elseawhy elseawhy commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

This pr fixes two distinct bugs that were causing dotfiles to be completely excluded from tab completion
( Closes #992 and #864 )

Bug 1:
Flyline's native filename expansion was hardcoded to always skip hidden files.

This pr allows flyline to read _rl_match_hidden_files directly from bash, it will now dynamically respect your standard bash config, users can simply add bind 'set match-hidden-files off' to their ~/.bashrc to stop dotfiles from showing.

Bug 2:
Even with the first fix, if a user had an alias like alias ls='ls --group-directories-first', flyline would expand the alias before asking Bash for completions. This is fine but if the user have bash-completion installed, which most users do, this will trigger a crude regex bug in bash-completion

In v2.18.0 of bash-completion, inside the generic _comp_complete_longopt function, bash-completion uses this exact code to guess what flags do:

            --!(no-*)dir*)
                _comp_compgen -a filedir -d;
                return
            ;;

Because --group-directories-first contains the word dir, the regex blindly assumes the user is trying to supply a directory argument to the flag, which forces compgen -d hiding all files

In this pr, flyline now detects self aliases, if the command is self aliased flyline will simply not expand it, which is exactly how native bash handles aliases, this prevents bug 2.

@elseawhy
elseawhy force-pushed the feature/match-hidden-files branch from 1385804 to dabbe03 Compare September 21, 2026 10:18
@elseawhy
elseawhy marked this pull request as draft September 21, 2026 14:52
@elseawhy elseawhy closed this Sep 21, 2026
@elseawhy
elseawhy force-pushed the feature/match-hidden-files branch from dabbe03 to 3b9e900 Compare September 21, 2026 14:56
@elseawhy

Copy link
Copy Markdown
Contributor Author

oh my god, i accidentally force pushed again ugh

@elseawhy elseawhy reopened this Sep 21, 2026
@elseawhy
elseawhy marked this pull request as ready for review September 21, 2026 14:58
@elseawhy
elseawhy force-pushed the feature/match-hidden-files branch 2 times, most recently from 6d64077 to 28046e5 Compare September 23, 2026 07:02
@elseawhy
elseawhy force-pushed the feature/match-hidden-files branch from 28046e5 to bbe56d5 Compare September 23, 2026 07:03
@elseawhy

elseawhy commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

I also removed should_skip_hidden cause it was redundant. When Flyline was using the glob crate to search the filesystem, if i understand correctly, should_skip_hidden was added to filter the dotfiles grabbed by glob in tab_complete_with_expanded_pattern

But on August 20th 2c1740e (PR #973), glob was removed from Flyline and switched to expand_iter(), since it already checks wants_hidden and filter the dotfiles, should_skip_hidden is simply not needed anymore

@HalFrgrd

Copy link
Copy Markdown
Owner

Thanks for the great fix again!

Do you think we should be observing bind 'set match-hidden-files off/on' or shopt -s dotglob ? I ask because I want to make sure the glob preview shows what bash will expand when running the command. e.g. If the user types ls ~/.* or ls ~/*, flyline will show the auto completions for each one. When they press enter, bash will expand the command before execution and it's important that what flyline shows in each case matches what bash will expand.

@elseawhy

elseawhy commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Yes, I think we could create a new PR for that later

Do you think we should implement exactly what bash + readline does?

Like iirc, if match hidden files on, dotglob off, hitting tab will show dotfiles but rm -rf * won't delete dotfiles, dotfiles are only deleted IF dotglob is turned on. If we are doing it this way, we just need to expose dotglob to flyline on top of this current pr.

Correct me if I'm wrong, but if we are going your route, eg only expand what is shown on tab completion, we just need to expose dotglob to flyline, match hidden files isn't needed anymore, but doing it this way means we have to filter the dotfiles expanded by CommandComp (completions generated by programmable completions) internally via flyline.

Right now in this pr, the dotfiles generated by CommandComp are filtered via readline, using the bind command that turns match hidden files off.

@HalFrgrd

Copy link
Copy Markdown
Owner

I spent some more time thinking about how things should work. I suppose there are three cases:

  • For CompType::GlobExpansion (e.g. when the user types ls ~/*), we should observe set -s/u dotglob.
  • For the CompType::CommandComp stuff, we shouldn't filter the results. We just show what we get back.
  • For CompType::FilenameExpansion / CompType::FuzzyFilenameExpansion, we should try and make this act like how CompType::CommandComp would act in terms of whether or not to show dotfiles when we the word under cursor doesn't start with a dot. (e.g. when we type asdf <tab> and no completion spec exists for asdf, CompType::FilenameExpansion is triggered and we should generate suggestions like those generated for ls <tab> assuming ls has a comp spec setup).

Do you think this is sensible?

@elseawhy

elseawhy commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Sure we could do that, since we are not gonna filter it inside flyline, that means we have to keep rl_match_hidden_files right ?

@HalFrgrd

HalFrgrd commented Oct 4, 2026

Copy link
Copy Markdown
Owner

I think we'll need rl_match_hidden_files for CompType::FilenameExpansion / CompType::FuzzyFilenameExpansion

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.

Tab completion always skips dotfiles, even with shopt -s dotglob

2 participants