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

System.NullReferenceException on Undo #425

Closed
workgroupengineering opened this issue May 22, 2024 · 2 comments · Fixed by #440
Closed

System.NullReferenceException on Undo #425

workgroupengineering opened this issue May 22, 2024 · 2 comments · Fixed by #440

Comments

@workgroupengineering
Copy link
Contributor

How to simulate:

  • Clone latest master 88625c4
  • Open AvaloniaEdit.sln
  • Run AvaloniaEdit.Demo
  • Go to line 62
  • Press Enter key
  • Click on Button Insert Snipet
  • Edit name in aaa and press Enter key for confirm the change
  • Press CTRL+Z four times
  • The exception will be thrown
@Rekkonnect
Copy link

The action of adding a snippet adds multiple lines and thus exposes the lack of checking whether the invalidated line range is out of bounds. The call stack shows that the exception is ultimately thrown by TextMateSharp because it attempts to read the line at the given index, without checking whether it's in bounds. This can be retrieved via the GetNumberOfLines() method from the model, and evaluated such that InvalidateLineRange(int, int) doesn't run the loop with out of bounds indexes.

@danipen Does this belong to https://github.com/danipen/TextMateSharp? Then this issue would track the respective issue in that repo.

@danipen
Copy link
Collaborator

danipen commented May 28, 2024

I'd say this should be fixed at this layer: https://github.com/AvaloniaUI/AvaloniaEdit/blob/master/src/AvaloniaEdit.TextMate/TextEditorModel.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants