PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

Fix/text changed event args changed range #215

Open codingdave opened 3 years ago

codingdave commented 3 years ago

Short: I have observed that the Range Start setter also changes the end field. That leads to

Long

I have fixed that issue in this PR. Because it is hard to see where this behavior (Start == End) is required I have added a function SetStartAndEnd that is explicitly doing what it says: Setting Start and End at the same time. Then I went through all the code and have inserted that function whereever Range.Start was assigned and not Range.End was assigned in the next line: TB.Selection.Start = new Place(0, LineIndex)

Also have left lines untouched that are assigning End to Start: Start = End;

In the second step I have changed the Range.Start setter to not any longer modify Range.End.

I have also created a sample application that demonstrates that behavior, but it is not part of this PR. You can find it here: https://github.com/codingdave/FastColoredTextBox/tree/fix/TextChangedEventArgs-ChangedRange-Sample

These are the screenshots of the sample. Green is unchanged text, Red is the ChangedRange and black is the new text that is added and not part of the ChangedRange, so you can say that is the error that this PR fixes.

Before the fix

2020-10-09_15-28-41

After the fix

2020-10-09_15-28-46

One further note: I have left the VB code untouched, as this is not my comfortable language.

codingdave commented 3 years ago

Hi @PavelTorgashov what do you think about this PR? Do you have any interest in this patch? If so, what is missing for you to accept this PR?

Kind regards

codingdave commented 3 years ago

Hi @PavelTorgashov any updates on this? Is this project dead?