`ListView` prediction breaks `RevertLine()`

Open
#5,047 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
cli

Research direction

Reproduce the problem in a pwsh -NoProfile session using the Ctrl+R handler and ListView prediction settings described above. Trace the interaction between RevertLine(), Insert(), and ListView prediction rendering. Done means pressing Ctrl+R replaces foo with Inserted Text rather than appending to it, with relevant tests updated or added if the repository provides coverage for this behavior.

Written by the indexing model from the issue text.

Description

Needs-Triage :mag:
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
N/A
Screenshot

Image

Environment data
PS Version: 7.5.4
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.7306 (WinBuild.160101.0800)
BufferWidth: 361
BufferHeight: 96
Steps to reproduce

In a pwsh -NoProfile session, run the following:

Set-PSReadLineKeyHandler -Chord "Ctrl+r" -ScriptBlock {
    [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
    [Microsoft.PowerShell.PSConsoleReadLine]::Insert("Inserted Text")
}

Set-PSReadLineOption -PredictionViewStyle ListView

Then, type foo (without pressing the enter key) and press Ctrl+R.

Expected behavior

Pressing Ctrl+R should replace foo by Inserted Text in the prompt.

Actual behavior

Pressing Ctrl+R adds Inserted Text to the existing foo: the end result is fooInserted Text in the prompt.

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.