Exception when deleting invalid command retained from ValidateAndAcceptLine in Vi Mode

Abierto
#3,919 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
cli

Línea de trabajo

Reproduce the sequence in a profile-free pwsh session: Vi mode, bind Enter to ValidateAndAcceptLine, enter an invalid command, press Escape, then dd. Start from the ValidateAndAcceptLine and ViChordHandler paths shown in the exception, and verify that deleting the current input completes without the IndexOutOfRangeException.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Issue-Bug Needs-More Investigation
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
### Environment
PSReadLine: 2.3.4
PowerShell: 7.4.0
OS: Microsoft Windows 10.0.22621
BufferWidth: 169
BufferHeight: 41

Last 114 Keys:

 S e t - P S R e a d L i n e O p t i o n Spacebar - E d i t M o d e Spacebar V i Enter S e t - P S R e a d L i n e K e y H a n d l e r Spacebar - K e y Spacebar E n t e r Spacebar - F u n c t i o n Spacebar V a l i d a t e A n d A c c e p t L i n e Enter n o t v a l i d Enter Escape d d

### Exception

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Text.StringBuilder.get_Chars(Int32 index)
   at Microsoft.PowerShell.PSConsoleReadLine.ConvertOffsetToPoint(Int32 offset)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.RenderWithPredictionQueryPaused()
   at Microsoft.PowerShell.PSConsoleReadLine.ClearStatusMessage(Boolean render)
   at Microsoft.PowerShell.PSConsoleReadLine.SaveEditItem(EditItem editItem)
   at Microsoft.PowerShell.PSConsoleReadLine.DeleteLineImpl(Int32 lineIndex, Int32 lineCount)
   at Microsoft.PowerShell.PSConsoleReadLine.DeleteLine(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ViChordHandler(Dictionary`2 secondKeyDispatchTable, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ViChord(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)
Screenshot

screenshot

Environment data
PS Version: 7.4.0
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.4
PSReadLine EditMode: Vi
OS: 10.0.22621.2428 (WinBuild.160101.0800)
BufferWidth: 169
BufferHeight: 41
Steps to reproduce

Start pwsh without profile, set edit mode to Vi, set Enter key handler to ValidateAndAcceptLine, enter a not valid command, press Escape to exit insert mode, enter dd

Expected behavior

The current input is deleted

Actual behavior

The above exception happens

Lenguaje dominante
C#
Estrellas
4.4k
Forks
341
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PowerShell/PSReadLine

Todos los issues de PowerShell/PSReadLine

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.