PowerShell / PowerShell

PowerShell for every system!
https://microsoft.com/PowerShell
MIT License
43.66k stars 7.08k forks source link

Incorrect Auto-Completion When Using Tab #23244

Closed JackW6809 closed 2 weeks ago

JackW6809 commented 3 weeks ago

Prerequisites

Steps to reproduce

Typing ip shows ipconfig as a suggested auto-completion. However, when pressing TAB it auto-completes it to ipal

Expected behavior

Pressing TAB button when presented with auto-complete should fill in the rest with what we are presented with.

Actual behavior

Pressing TAB button when presented with auto-complete instead fills it to a random cmdlet it thinks is correct, which is what happens on PowerShell 5.1.

Error details

No response

Environment data

PS C:\Users\jwillis> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image https://github.com/PowerShell/PowerShell/assets/53652452/67cc3405-8f92-4016-9b87-4651090b1f8b

MartinGC94 commented 3 weeks ago

That's not tab completion, it's prediction. The standard way to accept predictions is the right arrow key, you can bind it to Tab like this: Set-PSReadLineKeyHandler -Function AcceptSuggestion -Chord Tab but then you won't have your standard tab completion so I'd advice against it.

jhoneill commented 3 weeks ago

You're seeing IPConfig because that was the most recent command beginning with IP that you used. If I type IP I get IPMO module name

As @MartinGC94 says tab cycles through all commands beginning IP in alphabetical order, right arrow pulls back the whole of the line by default (so If you had ipconfig /flushdns you'd get the switch) In my profile I've set ctrl right arrow to pull back a word at a time, which IMHO makes the feature significantly more useful.

microsoft-github-policy-service[bot] commented 2 weeks ago

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

microsoft-github-policy-service[bot] commented 2 weeks ago

📣 Hey @JackW6809, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Microsoft Forms