Bug 154048 - Direct formatting without selection not taken into account on undo
Summary: Direct formatting without selection not taken into account on undo
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Undo-Redo
  Show dependency treegraph
 
Reported: 2023-03-07 19:38 UTC by Coburn Ingram
Modified: 2024-09-19 17:56 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Coburn Ingram 2023-03-07 19:38:41 UTC
Description:
Manually inserting a superscript in the text does not undo using backspace or <Ctrl-Z>. It persists after the superscript text is erased or undone.

Steps to Reproduce:
1.Go into superscript mode with the GUI button or <Shift+Ctrl+P>, or paste a previously created superscript character.
2. Type at least one number or letter, if you did not paste one already.
3.Change your mind and try to backspace or <Ctrl-Z> to return to normal text.

Actual Results:
The superscript character disappears, but Writer remains in superscript mode.

Expected Results:
Writer should return to normal text.


Reproducible: Always


User Profile Reset: No

Additional Info:
UserProfile should have no effect on this.
Comment 1 raal 2023-03-18 12:13:18 UTC
No repro with Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7a7eb4aa21ca0c83db825fe8d5a5278611b391d8
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded

Is your version LO 3.3 or did you tried it in actual version too?
Comment 2 Coburn Ingram 2023-03-18 18:58:36 UTC
Changed the release that this affects to indicate all releases in which I have personally experienced this behavior and remember doing so.
Comment 3 Stéphane Guillou (stragu) 2023-03-21 22:24:14 UTC
I see something different.
Using the following steps:
1. write "normal"
2. Ctrl + Shift + P
3. write "super"

On the undo stack there is (most recent at the top):
- Typing "super"
- Apply attributes
- Typing "normal"

I see two different behaviours depending on the next action:
(a) Ctrl + Z removes the superscript string, and continuing writing uses non-superscript characters *even though "Apply attributes" is still on top of the stack*
(b) Backspace until all superscript characters are gone, then continuing writing still uses superscript character

This not exclusive to superscripts, it is consistent with other formatting options (I tested bold, italic, font colour), but I feel like the two actions (Ctrl + Z vs backspace) are equivalent and should therefore have the same impact.
(a) seems particularly odd to me, in that "Apply attributes" is still in the history but new characters don't use the formatting. (I am aware this is the behaviour Coburn would prefer though.)

UX/UI team, what do you think?

Coburn, do you see something different following my steps? Please also share the info from Help > About LibreOffice.
I tested with this version:

Version: 7.5.1.2 (X86_64) / LibreOffice Community
Build ID: fcbaee479e84c6cd81291587d2ee68cba099e129
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: ru-RU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same results in 7.0.6.2
Comment 4 Heiko Tietze 2023-03-22 09:48:06 UTC
We continue text with the formatting before. It is a convenience function that you "switch the state" to superscript or to bold allowing to type ahead. In fact you apply the formatting to the selection and continue the formatting before.

This corner case with undo is somewhat tricky. We definitely want to keep undo when it is applied to a selection but I could imagine to not keep it in the undo stack if done without any selection. Mike, what do you think?
Comment 5 Mike Kaganski 2023-03-22 11:15:49 UTC
(In reply to Stéphane Guillou (stragu) from comment #3)
> On the undo stack there is (most recent at the top):
> - Typing "super"
> - Apply attributes
> - Typing "normal"
> 
> (a) Ctrl + Z removes the superscript string, and continuing writing uses
> non-superscript characters *even though "Apply attributes" is still on top
> of the stack*

(In reply to Heiko Tietze from comment #4)
> This corner case with undo is somewhat tricky. We definitely want to keep
> undo when it is applied to a selection but I could imagine to not keep it in
> the undo stack if done without any selection. Mike, what do you think?

Try this:

1. Type "normal"
2. Ctrl+Shift+P
3. Ctrl+Z

What is your expectation here?

Personally I believe that the bug is in comment 3, (a), that the first undo must keep the cursor inside the empty text run with modified properties created on the previous step, and the first undo there must not join the adjacent text runs with the same "normal" formatting.
Comment 6 Heiko Tietze 2023-03-22 12:38:51 UTC
(In reply to Mike Kaganski from comment #5)
> 1. Type "normal"
> 2. Ctrl+Shift+P
> 3. Ctrl+Z
> 
> What is your expectation here?

My proposal was to make it depending on whether something was selected.

> Personally I believe that the bug is in comment 3, (a), that the first undo
> must keep the cursor inside the empty text run with modified properties
> created on the previous step, and the first undo there must not join the
> adjacent text runs with the same "normal" formatting.

We can do this too. Would be more consistent and easier to understand but more challenging for the implementation, I guess.
Comment 7 Mike Kaganski 2023-03-22 12:40:54 UTC
(In reply to Heiko Tietze from comment #6)
> My proposal was to make it depending on whether something was selected.

And my question was what was *your* expectation when you did *the exact steps that I suggested*. And you didn't answer ;)
Comment 8 Heiko Tietze 2023-03-22 12:45:19 UTC
(In reply to Mike Kaganski from comment #7)
> And my question was what was *your* expectation when you did *the exact
> steps that I suggested*. And you didn't answer ;)

Because my proposal was straight-forward, or not? Any DF is not taken into the Undo stack if there is no selection. So Ctrl+Shift+P wouldn't be in the list and undo applies to #1.
Comment 9 Mike Kaganski 2023-03-22 13:15:44 UTC
(In reply to Heiko Tietze from comment #8)
> Ctrl+Shift+P wouldn't be in the list and undo applies to #1.

Then it would be impossible to simply change one's mind and *undo* the direct formatting application. Consider this sequence:

1. Type "normal".
2. Ctrl+Shift+P
3. Change your mind, and decide that you don't need the superscript.

Your options now are one of:

* Ctrl+Shift+P - this will *apply another DF*, explicitly setting "no superscript", where originally no DF was present;
* Move cursor outside of your position, then back.

The latter would work, unless you are at the empty paragraph: in this case, your action would change the paragraph properties. Would then this action require an undo action? And if yes, how would an average user see the difference, when it works, and when it doesn't?

The Ctrl+Z is natural when a user wants to undo the last action. Unless there is a *very* good reason to do otherwise, I think that we should allow undoing even such "empty" actions.
Comment 10 Coburn Ingram 2023-03-22 14:10:23 UTC
My request is just that the various undo methods would work consistently. I would like to be able to get out of superscript mode using the keyboard. To be honest, I am not a "shortcuts" person, although I have been using a few shortcuts since about 1985. And so when I see "Ctrl-Shift-P" in the comments, that is a good workaround. However, if I undo a superscript using backspace or Ctrl-Z, and it disappears, I should not still be in superscript mode.

Thanks
Comment 11 Buovjaga 2024-09-19 17:56:58 UTC
Already in 3.5.