carapace icon indicating copy to clipboard operation
carapace copied to clipboard

A bug in Powershell using the tab key

Open Shadow-XT opened this issue 11 months ago • 4 comments

Current Behavior

PowerShell: 7.4.1 Windows: 22631.3235 When entering a command in PowerShell, such as git or gh, an error such as "^ [[21; 22; 23; 24; 25; 29m ^ [[3" will appear after pressing the tab key, which will affect normal use, as shown in the figure below: image

Expected Behavior

If it is used normally, the following content should appear, and the excess "^ [[21; 22; 23; 24; 25; 29m ^ [[3" should not appear. image

Steps To Reproduce

No response

Version

0.30.2

OS

  • [x] Linux
  • [ ] OSX
  • [X] Windows

Shell

  • [ ] Bash
  • [ ] Elvish
  • [ ] Fish
  • [ ] Nushell
  • [ ] Oil
  • [X] Powershell
  • [ ] Xonsh
  • [ ] Zsh

Anything else?

No response

Shadow-XT avatar Mar 04 '24 13:03 Shadow-XT

Ok this will be hard because it works for me. The escape code should be one for the colored highlighting.

Is it only happening in gh <TAB> or somewhere else as well? Might be related to some alias or extension (name/description).

rsteube avatar Mar 04 '24 17:03 rsteube

Ok this will be hard because it works for me. The escape code should be one for the colored highlighting.

Is it only happening in gh <TAB> or somewhere else as well? Might be related to some alias or extension (name/description).

It also appears when using other commands, such as python, pip, etc., but with your reminder, I tried to modify my PowerShell Profile and found that the location of the loading configuration has a certain impact on whether the above bug will appear, as follows

#--------- configuration 1 ---------- 
Set-PSReadlineOption -EditMode Emacs
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
#---------------------------
#--------- configuration 2 ---------- 
#powershell (~/.config/powershell/Microsoft PowerShell_profile ps1)
Set-PSReadLineOption -Colors @{"Selection" = "'e [7m"}
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Carapace _carapace | Out-String | Invoke-Expression
#---------------------------

It turns out that I put configuration 2 before configuration 1, and the above bug will appear. Now after reversing the order, the previous bug has not been found for the time being.

Shadow-XT avatar Mar 05 '24 08:03 Shadow-XT

Seems to be related to the Emacs mode, i get the error on linux as well:

Set-PSReadlineOption -EditMode Emacs

Moving it above the other configuration fixes it indeed.

rsteube avatar Mar 05 '24 08:03 rsteube

Seems to be related to the Emacs mode, i get the error on linux as well:

Set-PSReadlineOption -EditMode Emacs

Moving it above the other configuration fixes it indeed.

It should be caused by this configuration. I tried to comment out the emacs mode, so the above problem will not occur. Thank you!

Shadow-XT avatar Mar 05 '24 14:03 Shadow-XT