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

#1909 (added in 2.2.0) forces Escape to clear the Vi mode inline completion #3420

Closed
3 tasks done
dominicpalmer opened this issue Aug 27, 2022 · 4 comments
Closed
3 tasks done
Labels
Resolution-By Design The behavior is by design.

Comments

@dominicpalmer
Copy link

dominicpalmer commented Aug 27, 2022

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

In both examples below, I am typing Install-, Escape and then l with EditMode set to Vi.

In 2.1.0, Escape exits insert mode (as expected) and doesn't clear the inline suggestion. This allows the user to complete the line with l, provided appropriate keybindings:

PSReadLine2 1 0

In 2.2.0-beta3, Escape exits insert mode but also clears the inline suggestion. This takes away the ability to navigate inline predictions in command mode.

PSReadLine2 2 0-beta3

I've tracked this down to #1909, which changed how Escape functions when predictions are visible in any view:

Escape (RevertLine) -- in the list view, it will revert to the original line, no matter whether or not a list item is selected, and clear the list view. So UpArrow and DownArrow can then be used to navigate history commands as normal.

IMO, the user should have control over whether or not the predictions view is cleared on Escape, when EditMode is Vi. Desired behaviour would be for Escape to exit insert mode, then for a second Escape to clear the view.

Environment data

PS Version: 7.2.6
PS HostName: ConsoleHost
PSReadLine Version: 2.2.0-beta3 (but likely introduced in 2.2.0-beta1)
PSReadLine EditMode: Vi
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 90
BufferHeight: 55

Steps to reproduce

  1. Use my PowerShell profile found at https://github.com/dominicpalmer/dotfiles/blob/master/windows/pwsh/Microsoft.Powershell_profile.ps1, which sets EditMode to Vi, and adds a PSReadLineKeyHandler for l that either sends ForwardChar if there isn't a prediction, or AcceptSuggestion if there is.
  2. Install version 2.2.0-beta3. Add the prediction ListView and also hook up with the CommandPrediction APIs introduced in PS 7.1 #1909, the change responsible, was introduced in 2.2.0-beta1. But I couldn't get beta1 or beta2 to work on my machine so beta3 is the earliest version to reproduce.
  3. Type something to trigger an inline prediction to show. Now hit Escape.
  4. The prediction is cleared.

Expected behavior

I expect the behaviour as seen in version 2.1.0, where Escape doesn't clear the prediction.

Actual behavior

The prediction is cleared.

@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Aug 27, 2022
@daxian-dbw
Copy link
Member

Entering the CMD mode means quitting general editing, so I'm not sure how much value there would be to display suggestion in that case. In your scenario, what is the difference from pressing RightArrow and then Escape?

@dominicpalmer
Copy link
Author

The first benefit is to avoid leaving the home row. Some Vi users have 60% keyboard form factors, where arrow keys are mapped to a hidden layer (requiring a layer toggle to access).

I don't use a 60% myself, but I'm familiar enough with hjkl for navigation that Escape + l is more natural than move right hand to arrow keys + RightArrow + Escape + Move right hand back to home row. 60% users would need that layer toggle added in somewhere too.

A subsequent benefit would be the ability to partially complete predictions by words using Vi motions like w, e and so on, as you can in Zsh. Example from Zsh running in WSL2:

zsh

Keeping predictions visible in command mode would be a precursor to this feature being added to PSReadLine at some point in the future.

@StevenBucher98
Copy link
Collaborator

We are marking this as expected behavior as when a user is out of edit mode in Vi, it does not make sense to have inline view show when they can't edit.

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Apr 6, 2023
@StevenBucher98 StevenBucher98 added the Resolution-By Design The behavior is by design. label Apr 6, 2023
@dominicpalmer
Copy link
Author

@StevenBucher98 Thank you for following up on this, however I do not agree that this should be closed as Resolution-By-Design. As mentioned, leaving the inline view accessible in command mode is needed for the following:

  • Line completion or partial line completion using l without having to go back into insert mode and without having to use arrow-keys (showcased in my original post)
  • Use of other command mode movements such as w, W, e and E to partially complete a full-line suggestion by one or more words at a time (showcased in my earlier reply). Visual Studio Intellicode/line-completions work in a similar way: users can partially accept completions by hitting Tab incrementally.

Besides, saying this doesn't make sense for PowerShell Vi is to also say it doesn't make sense for Zsh Vi, yet Zsh Vi does what I'm describing by default and has done for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-By Design The behavior is by design.
Projects
None yet
Development

No branches or pull requests

3 participants