Bug 140007 - UNDO Find and Replace leads to errors
Summary: UNDO Find and Replace leads to errors
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.6.2 release
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:7.5.0 target:7.4.0.0.beta2 tar...
Keywords: bibisected, bisected, regression
: 146274 146796 149793 (view as bug list)
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2021-01-29 19:45 UTC by R. Green
Modified: 2022-08-10 19:51 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer file demonstrating an UNDO bug (11.67 KB, application/vnd.oasis.opendocument.text)
2021-01-29 19:45 UTC, R. Green
Details

Note You need to log in before you can comment on or make changes to this bug.
Description R. Green 2021-01-29 19:45:33 UTC
Created attachment 169286 [details]
Writer file demonstrating an UNDO bug

Version: 7.0.4.2 (x64)
Build ID: dcf040e67528d9187c66b2379df5ea4407429775
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: threaded

This worked in previous versions, so presumably a very recent regression.

1. Open the attached Writer file. It consists of a series of short paragraphs.
2. Ensure the cursor is at the start, and open Find and replace. Tick "Regular expressions", put $ in the Find box and a space in the Replace box.
3. Press "Find Next", then keep pressing "Replace" until all sentences are separated by a space and in a single paragraph.
3. Put cursor focus back on document page (or close F&R dialog). Press Ctrl + Z (UNDO) and repeat …

EXPECTED RESULT: After each undo the sentence should appear as a separate paragraph.
ACTUAL RESULT: The paragraph breaks are lost!
Comment 1 BogdanB 2021-01-29 20:14:47 UTC
Confirm in
Version: 7.0.4.2
Build ID: dcf040e67528d9187c66b2379df5ea4407429775
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

The undo steps are lost.
Comment 2 BogdanB 2021-01-29 20:24:29 UTC
In my reaserch this is the first bad version
Version: 6.4.6.2
Build ID: 0ce51a4fd21bff07a5c061082cc82c5ed232f115
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3; 
Locale: ro-RO (ro_RO.UTF-8); UI-Language: en-US
Calc: threaded

--- here is the change causing the bug

In my reaserch this is the last good version
Version: 6.4.5.2
Build ID: a726b36747cf2001e06b58ad5db1aa3a9a1872d6
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3; 
Locale: ro-RO (ro_RO.UTF-8); UI-Language: en-US
Calc: threaded
Comment 3 pavlog 2021-04-21 20:47:10 UTC
Bisected it in win64-6.4
 1263e46cce67d5a3e00360c11fec4dbe1cf87bff is the first bad commit
commit 1263e46cce67d5a3e00360c11fec4dbe1cf87bff
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Sun Jun 14 13:07:41 2020 -0700

    source d6b0e84b236b78f4b21bd16e46dda3fa0876096d

    source d6b0e84b236b78f4b21bd16e46dda3fa0876096d

https://git.libreoffice.org/core/+/d6b0e84b236b78f4b21bd16e46dda3fa0876096d

commit d6b0e84b236b78f4b21bd16e46dda3fa0876096d	[log]
author	Michael Stahl <Michael.Stahl@cib.de>	Fri Jun 12 14:17:20 2020 +0200
committer	Caolán McNamara <caolanm@redhat.com>	Sun Jun 14 21:56:25 2020 +0200
tree 58f1f6c91777fff8c10df2f0d9b24d327c661c74
parent 2c2820b98c62e8de0806fd79c34b5fcf37f00c7e [diff]

Adding Cc: to Michael Stahl
Comment 4 Telesto 2021-04-22 07:50:58 UTC
Bisected to:

tdf#131912 sw: fix spell check correct deleting flys

* SwEditShell::ApplyChangedSentence() should not call
  DeleteAndJoin() + InsertString() but ReplaceRange()

* ReplaceRange() and SwUndoReplace need to set a new flag
  DelContentType::Replace to tell SwUndoSaveContent::DelContentIndex()
  not to delete flys but instead record the previous anchor positions

* SwUndoReplace::UndoImpl() should also not call DeleteAndJoin()
  + InsertString(); instead call ReplaceRange() for the start node
  and then DeleteAndJoin() for any regex "\n" that were inserted

(regression from 28b77c89dfcafae82cf2a6d85731b643ff9290e5)

Change-Id: I485d79510ae233213cb4b208533871934c5e5ec6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96201
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit e1629c210ad78310e3d48c0756723134a27b89df)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96204
Reviewed-by: Caolán McNamara <caolanm@redhat.com>

https://git.libreoffice.org/core/+/d6b0e84b236b78f4b21bd16e46dda3fa0876096d
Comment 5 Telesto 2021-04-22 07:51:41 UTC Comment hidden (no-value)
Comment 6 Gabor Kelemen (allotropia) 2022-02-02 21:45:57 UTC
*** Bug 146274 has been marked as a duplicate of this bug. ***
Comment 7 Mike Kaganski 2022-02-03 06:04:29 UTC
*** Bug 146796 has been marked as a duplicate of this bug. ***
Comment 8 Commit Notification 2022-06-10 12:59:45 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/45613274794636ba98d0e978fe872511297d275d

tdf#140007 sw: fix SwUndoReplace

It will be available in 7.4.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.
Comment 9 Michael Stahl (allotropia) 2022-06-10 13:05:47 UTC
fixed on master, just before branchoff...
Comment 10 Roland Kurmann 2022-06-11 09:43:11 UTC
> fixed on master, just before branchoff...

It seems the commit is just after the branchoff.
Comment 11 Michael Stahl (allotropia) 2022-06-13 09:07:36 UTC
(In reply to Roland Kurmann from comment #10)
> > fixed on master, just before branchoff...
> 
> It seems the commit is just after the branchoff.

you're right, it's before the branchoff only in time, not in the git log ... fortunately Xisco already uploaded it to gerrit for libreoffice-7-4
Comment 12 Commit Notification 2022-06-13 11:27:47 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/ceb01278d8593ab4d2562f934af4fb196342bdf8

tdf#140007 sw: fix SwUndoReplace

It will be available in 7.4.0.0.beta2.

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.
Comment 13 Commit Notification 2022-06-14 10:42:59 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/7df50ecd9dea623058dc7bf9095fd13d9bb49860

tdf#140007 sw: fix SwUndoReplace

It will be available in 7.3.5.

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.
Comment 14 Mike Kaganski 2022-06-30 17:36:02 UTC
*** Bug 149793 has been marked as a duplicate of this bug. ***
Comment 15 Gabor Kelemen (allotropia) 2022-08-10 19:51:06 UTC
Verified in 

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 4e2ce2a460458f17ee4360c45a2da2fc4b4d753e
CPU threads: 14; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded

Undo restores paragraph markers correctly.