Copying formatted text in non-formatted text layer doesn't generate an undo step
Environment/Versions
- GIMP version: master
- Operating System: probably all (Linux for sure)
Description of the bug
If you paste formatted text in a text layer with no local format so far (only the global format, such as font, font size, etc.), then no undo steps are created.
Reproduction
Is the bug reproducible? Always
Reproduction steps:
- Create a new image
- Create a new text layer with contents "Hello World"
- Select "World" and make it bold
- Select all text (Ctrl-A) and copy (Ctrl-C)
- Create a new text layer with contents "hi"
- Exit edition of text layer
- Make sure that the "Undo History" dockable is opened so that you can see new undo steps being created
- Re-click in text layer "hi" (anywhere) to get back to edition mode
- Paste (Ctrl-V)
Expected result: a new undo step is created for the text paste
Actual result: no undo step is created for text paste. Worse, if you undo (ctrl-z), you will likely undo the whole creation of the "hi" text layer since it's likely the last undo step in your history.
Additional information
It looks like adding text doesn't always create an undo step. I'm not sure when it does (probably when writing again after a timeout of some sort), but even this it doesn't look like enough. Like I am able to write whole paragraphs and undo would delete them completely. Undo in text processors feels a lot more fine-grained than this (it looks like at least it tokenized and undo word by word). But this could be another report as its own problem.
Here it looks like in some cases, pasting text inside a text layer doesn't even create an undo step. I think a text paste should always create an undo step (and not get into the probably-timeout-based mechanism of creating regular undo steps when typing).
It looks like this is triggered more easily with formatted text, but even unformatted text (in a different way): if I copy from an unformattext text layer, then paste, it does create an undo step, but further paste (e.g. I paste the same contents several times) doesn't. I think each paste should create an undo step!
When pasting formatted text (my steps above), the first paste does not create an undo step, but the second does, and from then on, no further undo steps are created.
Anyway it's a real mess which needs to be straightened up.