PavelTorgashov / FastColoredTextBox

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

[BUG] Delete -> Ctrl+Z changes the position of the cursor #167

Open nongcaro opened 5 years ago

nongcaro commented 5 years ago

Here's a GIF: Imgur

Hexman768 commented 5 years ago

What were the testing conditions when this gif was created?

Hexman768 commented 5 years ago

Looking at this gif now and having tested for the issue myself, when does it change the position of the cursor? All that happens is the cursor gets placed back where it was when you were making the change. I believe this is expected functionality, feel free to correct me if I am wrong.

Hexman768 commented 5 years ago

I take that back, I think I can see what you are talking about, do you mean when the cursor jumps forward by one character?

nongcaro commented 5 years ago

Hey @Hexman768, thanks for the reply.

Yeah, that's what I meant, sorry if I wasn't clear. It jumps forward by one character.

nongcaro commented 5 years ago

@Hexman768 For the testing conditions, it really doesn't matter. Anything that has a FastColoredTextBox has this issue.

nongcaro commented 5 years ago

I just tried implementing the Delete key myself, overriding it. But the problem is, now undo doesn't work. It just does delete again.

gif

nongcaro commented 5 years ago

Forget about the custom implementation. I did have a hacky solution to the problem: ok

But it doesn't work perfectly yet. It has conflictions with when using Delete and then writing something else, and then doing Ctrl+Z, and then doing Ctrl+Z for the Delete. However, I haven't tried fixing this yet, but I would really rather have an official solution because this is not the way Delete is supposed to work.

Hexman768 commented 5 years ago

I believe there is an official solution available, in the meantime could you add the bug label to this issue? When I get off work I will look into finding a code change that will resolve this issue.

nongcaro commented 5 years ago

Um lol, I don't think I can.

Hexman768 commented 5 years ago

Can you click on the labels button directly?

nongcaro commented 5 years ago

I don't have any label button @Hexman768. I think it's only available for owners/contributors. I'll just leave the [BUG] in the title for now.

Hexman768 commented 5 years ago

Sounds good, I didn't get a chance to look into this last night, I'll see if I have enough time tonight.

nongcaro commented 5 years ago

No problems. Thanks anyways!

nongcaro commented 5 years ago

Any news @Hexman768?

Hexman768 commented 5 years ago

Honestly, between school and work, I haven't had time to look into this issue and I probably won't have the time in the near future, we can choose to leave it open and I can get to it when I can or you can close it if you so choose.

nongcaro commented 5 years ago

Okay.

nongcaro commented 5 years ago

Never mind this, I implemented my own Delete function. It shows the selection after doing Undo, but it's way better than changing the cursor. The selection can simply be removed though (detecting it after the Undo). I'll leave this issue open because it's still technically a logical bug, and my solution is not official.

The way FastColoredTextBox implements Delete, is by moving the cursor one column to the right, and then inserting the character "\b" (backspace) (this method is private). And when you do Undo, it inserts the text back, and the cursor goes one position to the right when doing that, because that's what its place was before the backspace.