nightroman/FarNet

PSF: Pressing Tab in Editor throws an exception when "Cursor beyond end of line" is enabled

BuckPyland opened this issue · 3 comments

When editing a PowerShell script in Far Editor, pressing Tab on an empty line with the cursor past the end of line (such as when Auto Indent is enabled) causes the following exception to be thrown:

IndexOutOfRangeException:
Index was outside the bounds of the array.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at PowerShellFar.EditorKit.NeedsTabExpansion(IEditor editor)
   at PowerShellFar.EditorKit.OnKeyDownPSFile(Object sender, KeyEventArgs e)
   at FarNet.Editor0.AsProcessEditorInput(ProcessEditorInputInfo* info)
   at ProcessEditorInputW(ProcessEditorInputInfo* info)

An example of how to reproduce this:

  • Open a PowerShell script, or edit a new one, in Far Editor.
  • Set the following options, if not already set:
    [x] Cursor beyond end of line
    [x] Auto indent (not required for the example, but it makes my life easier 😄 )
  • Enter the following starting at any column > 1:
    if ($foo -eq "bar")<Enter>
    {<Enter>
  • At this point the cursor is on an empty line directly underneath the opening brace, "{".
  • Now, press Tab and you will see the message box referring to the exception. Selecting "[ More ]" will display the exception and stack trace in a new modal Editor.

Versions

  • Far Manager 3.0.4949 x64
  • FarNet and PowerShellFar 5.2.3

Thanks in advance,
Buck

Hi Buck,

Thank you for reporting the issue. I must admit "Cursor beyond end of line" is not tested well, I do not use this option. The bug should be fixed anyway. It should not take much time.

Please get the latest FarNet and PowerShellFar 5.2.4 and let me know how it goes.

That fixed it. Thanks, Roman.