Moeologist / scoop-completion

scoop tab completion, work with powershell
MIT License
172 stars 12 forks source link

question: variable name in src/scoop-completion.psm1 #11

Closed ghost closed 4 years ago

ghost commented 4 years ago

https://github.com/Moeologist/scoop-completion/blob/67025247793cb7b0febe56e0ae62f278a8f3deaa/src/scoop-completion.psm1#L55

is it supposed to be `$fliter'?

also, now importing scoop-completion also show completions for gc(get-content) and iwr (Invoke-WebRequest) and others that I can't recall yet.


regards ratatoeey

Moeologist commented 4 years ago

It means that scoop-completion offer completions to other commands? I'm confused about this. Would you mind explaining a little more detail?

ghost commented 4 years ago

It means that scoop-completion offer completions to other commands?

yes. it modifies the behaviour for other commands and shows additional stuff even for commands that are not preceded by scoop.

look at the two lines highlighted by red.

scoop-completion


regards ratatoeey

Moeologist commented 4 years ago

@ratatoeey

Set-PSReadlineKeyHandler will modify all existing TabCompletion behaviour. All TabCompletion will show menu rather than cycle words. scoop-completion doesn't handle gc commands. You can disable Import-Module scoop-completion, and try again.

C:\Users\ala
❯ Get-Module -All|Select-Object Name,Path|Sort -Property Path

Name                                     Path
----                                     ----
Microsoft.PowerShell.Commands.Management C:\Dev\Scoop\apps\pwsh\current\Microsoft.PowerShell.Comma…
Microsoft.PowerShell.Commands.Utility    C:\Dev\Scoop\apps\pwsh\current\Microsoft.PowerShell.Comma…
Microsoft.PowerShell.Management          C:\dev\scoop\apps\pwsh\current\Modules\Microsoft.PowerShe…
Microsoft.PowerShell.Utility             C:\dev\scoop\apps\pwsh\current\Modules\Microsoft.PowerShe…
Microsoft.PowerShell.PSReadLine2         C:\dev\scoop\apps\pwsh\current\Modules\PSReadLine\Microso…
PSReadLine                               C:\dev\scoop\apps\pwsh\current\Modules\PSReadLine\PSReadL…
posh-vcpkg                               C:\Dev\vcpkg\scripts\posh-vcpkg\0.0.1\posh-vcpkg.psm1
npm-completion                           C:\Users\ala\Documents\PowerShell\Modules\npm-completion\…
posh-git                                 C:\Users\ala\Documents\PowerShell\Modules\posh-git\1.0.0\…
PSColor                                  C:\Users\ala\Documents\PowerShell\Modules\PSColor\1.0.0.0…
yarn-completion                          C:\Users\ala\Documents\PowerShell\Modules\yarn-completion…

C:\Users\ala
❯ gc -v

Press Tab Key

ghost commented 4 years ago

Set-PSReadlineKeyHandler will modify all existing TabCompletion behaviour.

oh, so there is no way to avoid it.

Maybe microsoft could add a option to not display the extra stuff in powershell 6.2, its not happening anymore on powershell 5.1 I might have mixed things up. i filed the issues https://github.com/MicrosoftDocs/PowerShell-Docs/issues/5046 https://github.com/MicrosoftDocs/PowerShell-Docs/issues/5045. update: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/5046 to https://github.com/MicrosoftDocs/PowerShell-Docs/issues/5046#issuecomment-548947956


scoop-completion doesn't handle gc commands.

got it. it can't be helped but gc parameters will be displayed. and scoop-completion is not called for gc. right?

You can disable Import-Module scoop-completion, and try again.

disabled it, tried again and it was back to normal. obviosuly, scoop parameters were not getting auto-completed.

so then I enabled it again, and it was back, so this is the same behaviour as before. I thought you meant that disabling it would fix it somehow, though it didn't make sense to me as no code had been changed in scoop-completion or powershell 6.2 in disabling. I disabled it by commenting it out in $profile for Powershell 6, just so we are clear.


i think you forgot or I forgot to read the answer. so repeating again, in

https://github.com/Moeologist/scoop-completion/blob/67025247793cb7b0febe56e0ae62f278a8f3deaa/src/scoop-completion.psm1#L55

is it supposed to be `$fliter'

after :ScoopAlias( , as I think it might be a mistake and should be $filter like in other functions in the same ffile.


regards ratatoeey

Moeologist commented 4 years ago

Sorry...I mislead you. Code has no matter(ScoopAlias handle subcommand by scoop alias). But this line:

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

It is not a good idea. I shoud not modify user profile in a module. I have removed this line from scoop-completion.Please upgade scoop-completion and try.

Moeologist commented 4 years ago

Extra stuff was caused by MenuCompletion.Set-PSReadLineKeyHandler only set shortcut.

ghost commented 4 years ago

after updating second line of extra stuff is gone. see screenshot above.

now only the first line of extra stuff is left.

should the version number be also bumped, its still 0.1.0? I just find it a bit odd, but no big deal.

> scoop list scoop-completion
Installed apps matching 'scoop-completion':

  scoop-completion 0.1.0 [scoop-completion]

regards ratatoeey

Moeologist commented 4 years ago
scoop update
scoop update scoop-completion

I will fix "fliter" spelling mistake above. Thank you very much.

ghost commented 4 years ago

thanks for everything, I might have forgot to run scoop update scoop-completion after running scoop update.

updated successfully.

scoop-completion 0.1.1 [scoop-completion]

feel free to close the issue. as I think the first line extra stuff can not be configured unless PSReadline gets enhanced. and all my issues were resolved, and I learned some stuff.


regards ratatoeey