microsoft / inshellisense

IDE style command line auto complete
MIT License
8.21k stars 179 forks source link

Ctrl-A - inshellisense restart with "inshellisense session [live]" #181

Closed aranwe closed 4 months ago

aranwe commented 4 months ago

Describe the bug When I press Ctrl-A in powershell (7) in Windows Terminal the prompt closes (deleting anything written) and inshellisense restarts with message: inshellisense session [live]

To Reproduce Steps to reproduce the behavior:

  1. Go to powershell with inshellisense enabled
  2. Press Ctrl-A
  3. See message "inshellisense session [live]"

Expected behavior Powershell selects all text in the current prompt

Environment

Additional context Add any other context about the problem here.

aranwe commented 4 months ago

image

aranwe commented 4 months ago

Interesting - I have found a file: ~\.inshellisense\key-bindings-pwsh.ps1 with contents:

Set-PSReadLineKeyHandler -Chord 'Ctrl+a' -ScriptBlock {
    $command = $null
    [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null)

    $oldPrompt = $function:prompt
    function prompt { "`r" }
    [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
    $prompt = $oldPrompt

    [Microsoft.PowerShell.PSConsoleReadLine]::ClearKillRing()
    [Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine()
    [Microsoft.PowerShell.PSConsoleReadLine]::KillLine()

    $inshellisense = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js"
    if ($command) {
        Start-Process -NoNewWindow -Wait "node" "$inshellisense -c $command -s pwsh"
    }
    else {
        Start-Process -NoNewWindow -Wait "node" "$inshellisense -s pwsh"
    }

    $executedCommand = node $inshellisense --history
    if ($executedCommand) {
        [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executedCommand)
    }
    [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

that pretty much sets the ctrl+a behaviour -> is this intended as I do not recall creating this config file.

cpendery commented 4 months ago

@aranwe you can run is uninstall to remove any of the leftover artifacts from previous releases. This key binding was part of an early release that has been fully removed now.