PowerShell / CompletionPredictor

MIT License
145 stars 9 forks source link

PowerShell with imported `CompletionPredictor` crashes on `git diff` command #22

Closed kborowinski closed 1 year ago

kborowinski commented 1 year ago

Prerequisites

Steps to reproduce

Environment:

  1. Latest daily PowerShell Core 7.4.0.preview-2 build
  2. Latest CompletionPredictor module build (with git completion support)
  3. PSReadLine 2.3.0-beta0
  4. PowerShell profile:
    
    Import-Module -Name 'CompletionPredictor'

Set-PSReadLineOption -HistoryNoDuplicates Set-PSReadLineOption -PredictionSource 'HistoryAndPlugin'

Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

$Parameters = @{ Key = 'RightArrow' BriefDescription = 'ForwardCharAndAcceptNextSuggestionWord' ScriptBlock = { param($key, $arg) $line = $null $cursor = $null [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([Ref]$line, [Ref]$cursor) if ($cursor -lt $line.Length) { [Microsoft.PowerShell.PSConsoleReadLine]::ForwardChar($key, $arg) } else { [Microsoft.PowerShell.PSConsoleReadLine]::AcceptNextSuggestionWord($key, $arg) } } } Set-PSReadlineKeyHandler @Parameters


Steps:
```powershell
mkdir test
cd .\test\
git init
mkdir empty
git diff

Expected behavior

git diff should not crash PowerShell session

Actual behavior

PowerShell session crashes

Error details

N/A

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.2
PSEdition                      Core
GitCommitId                    7.4.0-preview.2-35-g78f1406fd2fed68aa6348df565b6824f8c187ef9
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.1.0

Visuals

crash

daxian-dbw commented 1 year ago

@kborowinski Thank you for dogfooding the git handler changes! I just merged some fixes (#23) for issues I found while using the module, and I think this issue was also resolved by that PR. Can you please build and give it a try? Thanks!

kborowinski commented 1 year ago

@daxian-dbw Yep, PR #23 fixed this issue. Thanks!

daxian-dbw commented 1 year ago

Thanks for verifying it! I appreciate it.