Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViMode crashed during c-F ViReplaceToCharBackward operation, attempting to specify ^ beginning of line. #4423

Open
3 tasks done
AltitudeApps opened this issue Feb 1, 2025 · 3 comments
Labels
Needs-Triage 🔍 It's a new issue that core contributor team needs to triage.

Comments

@AltitudeApps
Copy link

AltitudeApps commented Feb 1, 2025

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

PS C:\Users\Home> `
          (GEt-Item $_.Path) | % {
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!      $_.BaseName
                $_.DirectoryName
### Environment;
PSReadLine: 2.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
PowerShell: 7.5.0-rc.1Object -Property Count -Descending `
OS: Microsoft Windows 10.0.19045
BufferWidth: 195 -f blue $_.Group[0].Hash;
BufferHeight: 48oreach{
          }
Last 200 Keys:
    }
 c t Backspace Backspace Backspace l e c t - f o r k * " Spacebar ` Enter Backspace LeftArrow } Shift+Spacebar Enter O v e o p g a v e r Enter UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow DownArrow DownArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow DownArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow Enter UpArrow UpArrow UpArrow UpArrow UpArrow Enter UpArrow LeftArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow DownArrow DownArrow DownArrow Ctrl+[ d d UpArrow p UpArrow UpArrow p DownArrow DownArrow d d Enter UpArrow LeftArrow LeftArrow LeftArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow Ctrl+[ d 8 d k k k k k o p Backspace Ctrl+[ p x Ctrl+[ Backspace Backspace x UpArrow p x UpArrow Ctrl+c UpArrow DownArrow DownArrow UpArrow RightArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow UpArrow UpArrow DownArrow d 8 d k k k k k p < Backspace x Ctrl+[ Backspace x RightArrow LeftArrow i Ctrl+[ < Backspace x DownArrow DownArrow DownArrow UpArrow UpArrow UpArrow Shift+DownArrow Shift+DownArrow Shift+DownArrow Shift+RightArrow Shift+RightArrow w c F ^ l s

### Exception

System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Microsoft.PowerShell.PSConsoleReadLine.StartEditGroup()
   at Microsoft.PowerShell.PSConsoleReadLine.GroupUndoHelper.StartGroup(Action`2 instigator, Object instigatorArg)
   at Microsoft.PowerShell.PSConsoleReadLine.ViInsertWithDelete(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)


PS C:\Users\Home> `
          (GEt-Item $_.Path) | % {
            $x = $(
                $_.Mode
                $_.LastWriteTime
                $_.BaseName
                $_.DirectoryName
              );
            $x -join ", "
  $moreThanOne | Sort-Object -Property Count -Descending `
  | % {
      Write-host -f blue $_.Group[0].Hash;
      $_.Group.Foreach{
          }
        }
    }

Screenshot

just after the exception:

Image

what was in my buffer the moment before:

Image

Environment data

PS Version: 7.5.0-rc.1
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.6
PSReadLine EditMode: Vi
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 195
BufferHeight: 48

Steps to reproduce

repro:

  1. open a powershell terminal. (either 5.1 or or 7)
  2. invoke Set-PSReadlineOption -editMode vi
  3. enter some text at the prompt
  4. press Esc to switch to vi command mode
  5. press the following keys: c F ^ c F
  6. now press ^ a final time, and the exception will occur.

screenshot here: #4423 (comment)

unfortunately I am unable to reproduce the issue in a fresh pwsh tab.
PLEASE STAND BY... I have been able to reproduce this in a fresh environment, by attempting the operation twice. I keep getting interrupted, but I intend to provide a full repro later today.

Expected behavior

Not sure what I would expect, because I was just experimenting with Vi mode, trying to remove spaces from the beginning of a line. As far as I know, the key keystrokes that I was using are not a valid way of performing the operation that I was attempting; I was just experimenting to see what would happen.

Larger context: I was trying to unindent a block of code which I had cut from below with 'd 8 d', and then pasted at the top with a 'p' command.

Actual behavior

** BOOM **

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Feb 1, 2025
@AltitudeApps
Copy link
Author

AltitudeApps commented Feb 1, 2025

ALSO: the record of the 'last keys pressed' contain things I don't remember doing:

... Shift+RightArrow Shift+RightArrow w c F ^ l s

l? s?

(I guess this could have just been me reflexively typing ls?)

@AltitudeApps
Copy link
Author

AltitudeApps commented Feb 1, 2025

OK, I tried to reproduce the issue in the original terminal tab, which is still open, and doing c F ^ <something> did not result in an exception. In fact, it did nothing.

But then, I tried it again, and BOOM

But this time I landed back at the prompt, with the buffer in the state it was in before I started to navigate up to near the top, which is where I was going to attempt to perform the intended edits.

ALSO: I am now (nearly) stuck in the buffer. Ctrl-C and Esc have no effect. I can only press Enter to evaluate the buffer as-is.

Image

@AltitudeApps
Copy link
Author

repro:

  1. open a powershell terminal. (either 5.1 or or 7)
  2. invoke Set-PSReadlineOption -editMode vi
  3. enter some text at the prompt
  4. press Esc to switch to vi command mode
  5. press the following keys: c F ^ c F
  6. now press ^ a final time, and the exception will occur.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage 🔍 It's a new issue that core contributor team needs to triage.
Projects
None yet
Development

No branches or pull requests

1 participant