Bug 165973 - Don't delete the newline after unwanted autocorrect is undone
Summary: Don't delete the newline after unwanted autocorrect is undone
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.2 all versions
Hardware: All All
: medium enhancement
Assignee: Justin L
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks: AutoCorrect-Complete Undo-Redo
  Show dependency treegraph
 
Reported: 2025-03-30 10:41 UTC by Kuba Orlik
Modified: 2025-10-08 17:06 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Screencast of the issue (1017.45 KB, video/mp4)
2025-03-30 10:42 UTC, Kuba Orlik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kuba Orlik 2025-03-30 10:41:11 UTC
Description:
Sometimes when pressing Enter/Return to create a new line, auto-correct kicks in and changes the capitalization of the word, according to the defined set of rules. 

So if I start a new line, type "intentionally-lowercase" and press Enter, it gets corrected to "Intentionally-Lowercase".

When I then press ctrl+z, the word gets reverted to original spelling, but the newly entered newline is deleted. So if I then go to the end of the line and press Enter again... the autocorrect is applied again and the first letter is changed to a capital letter. So the user is stuck in a frustrating loop.

Note that the behavior for entering a newline is different from the behavior when pressing the spacebar.

If I start a line with "intentionally-lowercase" and then press Space, it adds a space and applies autocorrect. I can then press ctrl+z and it only undoes the autocorrect, keeping the space that I've entered, so I can move on with editing the document.

There's an unintuitive difference in behavior then: when pressing Space, autocorrect is treated as a separate step that can be undone. When pressing Enter, the newline and autocorrect are treated as one and can only be undone as a whole, leading to confusion.

I personally thing the behavior that's applied when pressing Space is more intuitive and it would be great if the same behavior was applied when pressing Enter

Steps to Reproduce:
1. In a new line, write a word starting with a lowercase letter
2. Press Enter
3. The word is now capitalized
4. Press ctrl+z

Actual Results:
The word is no longer capitalized, but the newline is gone

Expected Results:
The word is no longer capitalized, but the newline is still there and the cursor doesn't change position


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 520(Build:2)
CPU threads: 16; OS: Linux 6.13; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
25.2.2-1
Calc: threaded
Comment 1 Kuba Orlik 2025-03-30 10:42:12 UTC
Created attachment 200091 [details]
Screencast of the issue
Comment 2 BogdanB 2025-03-30 13:59:45 UTC
Confirm with
Version: 25.2.1.1 (X86_64) / LibreOffice Community
Build ID: e538fb6403facdfd3db0250c3b3278236c675c2a
CPU threads: 16; OS: Linux 6.11; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 3 Justin L 2025-10-02 14:30:42 UTC
Nicely written bug report! Thanks.

repro in OOo 3.3 (but in that case the first undo removes the newline, and the second undo removes the autocorrection).

The two were separate until 6.2 commit 391134e4cc0cf444ac50c6df02073de57ad9c466
Author: Nickson Thanda on Fri Jun 22 04:59:16 2018 +0100
    tdf#51223 can now undo auto-capitalise with enter

So the request is that the undo be split into two pieces again, and that the order be switched around.  (makes good sense, but probably tricky...)
Comment 4 Commit Notification 2025-10-08 11:59:03 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/906ee7050702e36b7509398cd33fd35597eaf528

tdf#165973 sw undo: separate AUTOFORMAT after SPLITNODE

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.