PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.75k stars 296 forks source link

BackwardDeleteWord not working if cursor on the end of line #536

Closed dbielik closed 7 years ago

dbielik commented 7 years ago

Environment data

PS version: 5.1.14409.1005 PSReadline version: 1.2 os: 6.3.9600.16384 (winblue_rtm.130821-1623) PS file version: 10.0.14409.1005 (rs1_srvoob.161208-1155)

Steps to reproduce or exception report

Set-PSReadlineKeyHandler -Chord 'Ctrl+w' -Function BackwardDeleteWord Type some text, press Ctrl+W, if cursor on the end of line, exception raised

Exception:
System.IndexOutOfRangeException: Индекс находился вне границ массива.
   в System.Text.StringBuilder.get_Chars(Int32 index)
   в Microsoft.PowerShell.PSConsoleReadLine.ViFindPreviousWordPoint(Int32 i, String wordDelimiters)
   в Microsoft.PowerShell.PSConsoleReadLine.BackwardDeleteWord(Nullable`1 key, Object arg)
   в Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignore
IfNoAction, Object arg)
   в Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   в Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

On any other position works as expected

gwojan commented 7 years ago

As a workaround I have mapped Ctrl+w to BackwardDeleteWord. It works but doesn't get the word boundaries correct like vim.