MenuComplete: Improve tab completion in Filesystem providers #4038
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR aims to improve the tab completion experience when using the MenuComplete function in filesystem providers (or analogous providers). It targets 2 bugs and streamlines inconsistent behavior in a 3rd QoL issue.
These are:
Spacebar
on a path containing whitespace will incorrectly autocomplete a single path in spite of multiple ambiguous paths existing.Tab
fails to complete containers (directories) when their full name is manually typed out (or backspaced into) when a menu is open.Description / Reproduction
cd C:/program
and pressTab
. You'll have something like these options:If you try to press
SpaceBar
in order to exclude ProgramData, you will instead autocompleteProgram Files
and enter its directory, even thoughProgram Files (x86)
would have also been viable at that point.=> Fixed so that pressing
Spacebar
in this context does not autocomplete the entire word.Pressing
Tab
can fail to complete containers (directories) when manually typed out in a menu.Type
cd C:/
and pressTab
to open a menu.Type
usr
and pressTab
.You will have
cd C:/usr/
open, but the final/
is a suggestion, and no further presses of tab will complete this slash.=> Fixed so that manually typing a directory name and pressing
Tab
will complete it including the directory separator.Inconsistent / tedious behavior when autocompleting a single, unambiguous container within the menu.
Navigate to the PSReadLine module home directory. There are 2 folders here that begin with "P", Polyfill and PSReadLine.
First, type
cd PS
and press tab. You will correctly complete tocd .\PSReadline\
. This is because a menu was avoided.Instead, try typing
cd P
and thenTab
. This will open a menu. Types
followed byTab
. You will end up stuck before the directory separator character (similar to bug 2 but for a different reason).=> This has been made consistent, so that an open menu will complete the same as no menu. This is also a QoL fix that streamlines using a menu, making it faster to tab through nested directories when navigating the filesystem. Ideally this would make
MenuComplete
as quick to use as functionComplete
while retaining the benefit of offering a menu.All of the fixes are localized in one region of the code, except the first fix, which is on line 774.
Miscellaneous
As this is my first time contributing, please let me know if there's anything I should consider in my PR. I'm also happy to engage in any discussion.
Tested
MenuComplete
functionality works for Containers, and doesn't impact, e.g., commands.Tested on Windows 10 with PS 7.4.2 and PS 5.1.19041.
PR Checklist
Microsoft Reviewers: Open in CodeFlow