orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
624 stars 38 forks source link

Multiple cursors disappear on undo & redo #480

Closed rgrams closed 8 months ago

rgrams commented 9 months ago

Using Textadept 12.1, on Linux. (Linux Mint 21.1)

The issue is simple: when I have multiple cursors active, type something, then press Ctrl-Z to undo, all of the extra cursors disappear, leaving only the last one.

The same thing happens on Redo.

https://github.com/orbitalquark/textadept/assets/11370192/71d58a5c-8a0e-4600-b95e-fc7b1423fec2

Unfortunately this makes the whole multiple-cursors feature in Textadept useless for me, since it's too frustrating when they constantly disappear. :(

orbitalquark commented 9 months ago

Unfortunately, Scintilla (Textadept's editing component) does not support cursor/caret undo/redo. It just has content/text undo/redo. Caret undo/redo would be a nice feature to have, though. It looks like something similar was brought up in the past: https://groups.google.com/g/scintilla-interest/c/SIII1GuHcR4/m/vUo-W9FYCAAJ.

rgrams commented 9 months ago

Hmm...I'm not sure that's the same thing? I haven't encountered a situation where undo or redo changes a single cursor's position unexpectedly, and I wouldn't want cursor movement or adding a new cursor to be entered into the undo stack. The problem seems to be that multiple cursors are deliberately destroyed on undo and redo, instead of simply being unaffected.

[Edit:] I just tried SciTE, and its behavior is exactly the same as Textadept's. So it does seem likely that this is a bug/poor choice in Scintilla. :(

[Edit2:] ZeroBrane Studio must use Scintilla too, because it has exactly the same broken behavior. :( :(

georgeraraujo commented 9 months ago

[Edit2:] ZeroBrane Studio must use Scintilla too, because it has exactly the same broken behavior. :( :(

Yes, ZeroBrane uses Scintilla. Notepad++, which is Windows-only, also does, and has the same behavior.

orbitalquark commented 9 months ago

You're right that the issue I linked to is not exactly the same thing. I knew what you meant though.

I looked into it this morning and came up with a possible fix for Scintilla. I've asked on the mailing list: https://groups.google.com/g/scintilla-interest/c/MdtNwj5wId4. We'll see what happens.

rgrams commented 9 months ago

Ah, awesome! Thanks for looking into it.

orbitalquark commented 8 months ago

Update: Neil replied on the Scintilla mailing list. This is tricker than it looks, so it's likely that the existing behavior of undo/redo clobbering multiple cursors will remain :(

rgrams commented 8 months ago

Gotcha, okay. Too bad. :(

From the thread:

If you have multiple selections active and you are typing into all of them at once, but perform undo, you lose those multiple selections. It would be really helpful to leave them be.

That may lead to situations with unexpected (and potentially off-screen) selections and thus extra unintended copies of added text.

This could be interpreted in different ways, but it seems like he might object to/not understand the main purpose of multiple cursors, so I can't imagine the behavior will be fixed in Scintilla either. Oh well. At least now I know that Scintilla-based editors won't cut it for me.

Thank you very much for taking the time to look into this. Textadept looks pretty cool otherwise. Feel free to close this as a "can't fix" if you want to keep your issues tidy.