Exceptions working with collapsed sections and using RectangleSelection #202

Open
opened 2019-10-16 10:15:54 -05:00 by FrankyB5 · 1 comment
FrankyB5 commented 2019-10-16 10:15:54 -05:00 (Migrated from github.com)

Hi!
When using a RectangleSelection, using the Alt keyboard and mouse, while having collapsed sections, causes exception. I've put both exceptions in this issue, since they seem to be related.

First exception is: an InvalidOperationException with the message "Line 42 was skipped by a VisualLineElementGenerator, but it is not collapsed.",

Repro:

  • Launch Sample application, and have text:

Welcome to AvalonEdit!
if
{
}

if
{
}

  • Using the Alt keyboard key, select from the first line and column, to the last line, and after the last bracket (selecting only 1 char wide).

image

  • Collapse the first section
  • Press delete. Boom.

Second related exception ArgumentOutOfRangeException with: "0 <= offset <= 1550
Parameter name: offset
Actual value was 1987."

Repro:

  • Input same text as previous exception.
  • Collapse both sections
  • Using the Alt keyboard key, select past the first character and take a few on the right. And go down all the way.

image

  • Press Delete

I haven't found any quick fixes or workarounds for this.

Let me know if you have any clues or any tips to have that fixed.
Thanks
François

Hi! When using a RectangleSelection, using the Alt keyboard and mouse, while having collapsed sections, causes exception. I've put both exceptions in this issue, since they seem to be related. First exception is: an InvalidOperationException with the message "_Line 42 was skipped by a VisualLineElementGenerator, but it is not collapsed.",_ **Repro**: - Launch Sample application, and have text: > Welcome to AvalonEdit! > if > { > } > > if > { > } - Using the Alt keyboard key, select from the first line and column, to the last line, and after the last bracket (selecting only 1 char wide). ![image](https://user-images.githubusercontent.com/17426039/66931906-a79dcb00-efeb-11e9-8468-776db19871fe.png) - Collapse the first section - Press delete. Boom. Second related exception ArgumentOutOfRangeException with: "_0 <= offset <= 1550 Parameter name: offset Actual value was 1987."_ **Repro:** - Input same text as previous exception. - Collapse both sections - Using the Alt keyboard key, select past the first character and take a few on the right. And go down all the way. ![image](https://user-images.githubusercontent.com/17426039/66932035-d9169680-efeb-11e9-9013-ec807b843461.png) - Press Delete I haven't found any quick fixes or workarounds for this. Let me know if you have any clues or any tips to have that fixed. Thanks François
mzbik commented 2020-09-17 17:11:01 -05:00 (Migrated from github.com)

You can make this simpler by deleting a box that contains a collapsed region at the end of the file with no EOL or deleting a collapsed region that includes more than the EOL. Basically, you get called to generate a line at EOF (offset == document length) and the code asserts since you're at EOF.

N.B., there's an issue in that the Folding data for the lines isn't updated when the Selection is updated (which then uses the Folding generator to produce lines). This ordering dependency should be handled explicitly in TextArea::OnDocumentChanged rather than relying on notification ordering.

You can make this simpler by deleting a box that contains a collapsed region at the end of the file with no EOL or deleting a collapsed region that includes more than the EOL. Basically, you get called to generate a line at EOF (offset == document length) and the code asserts since you're at EOF. N.B., there's an issue in that the Folding data for the lines isn't updated when the Selection is updated (which then uses the Folding generator to produce lines). This ordering dependency should be handled explicitly in TextArea::OnDocumentChanged rather than relying on notification ordering.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-icsharpcode/AvalonEdit#202
No description provided.