Bug 147583 - Search and Replace: cannot find end of paragraph (regex $) in backwards search (find previous)
Summary: Search and Replace: cannot find end of paragraph (regex $) in backwards searc...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low minor
Assignee: Justin L
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2022-02-21 16:15 UTC by Anduril
Modified: 2024-03-21 10:00 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (22.65 KB, application/vnd.oasis.opendocument.text)
2022-02-21 16:43 UTC, Anduril
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anduril 2022-02-21 16:15:48 UTC
Actual Behaviour:
Search and Replace: when searching paragraphs $, find previous button brings to the beginning of the document

Expected Behaviour
Search and Replace: when searching paragraphs $, find previous button should bring to the previous paragraph

Reproduce
Follow steps in Actual Behaviour
Comment 1 Xisco Faulí 2022-02-21 16:38:10 UTC Comment hidden (obsolete)
Comment 2 Anduril 2022-02-21 16:43:18 UTC
Created attachment 178445 [details]
Test case
Comment 3 Rainer Bielefeld Retired 2022-02-21 18:48:29 UTC
Reproducible with reporter's sample document and Installation of Version 7.3.0.3 (x64), Build ID 0f246aa12d0eee4a0f7adcefbf7c878fc2238db3
CPU threads: 12; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win | Locale: de-DE (de_DE); UI: de-DE | Calc: threaded | ElementaryTheme | My normal User Profile

Wrong STR:
1. Open Testcase in Writer
2. Menu ˋEdit  → Search and Replaceˊ
   » Dialog opens
3. As search therm type "laborum.$"
4. Check "Regular Expressions"
5. [Find next] (several times).
   » As expected "laborum." one by one will be highlighted from top to bottom
6.[Find previous] (several times).
   » As expected "laborum." one by one will be highlighted from last hit upwards

But reproducible with correct STR:
11. Open Testcase in Writer
12. Menu ˋEdit  → Search and Replaceˊ
   » Dialog opens
13. As search therm type "$"
14. Check "Regular Expressions"
15. [Find next] (several times).
   » As expected free space behind any "laborum." at end of paragraph one by 
     one will be highlighted from top to bottom
16.[Find previous] (several times).
   Expected: free space behind any "laborum." at end of paragraph one by 
     one will be highlighted from last hit to top of document.
   Bug: no end of paragraph found until top of document  😥
   » search therm "$" color switches to red because no search hit.
Comment 4 Rainer Bielefeld Retired 2022-02-21 18:55:45 UTC
No obvious DUP found with query <https://bugs.documentfoundation.org/buglist.cgi?cmdtype=dorem&remaction=run&namedcmd=DUPs147583&sharer_id=19321>
Comment 5 Rainer Bielefeld Retired 2022-02-21 19:09:20 UTC
Additional info:
a) Already REPRODUCIBLE with Server Installation of Version: 6.0.7.3 (x64) 
Build-ID dc89aa7a9eabfd848af146d5086077aeed2ae4a5; CPU-Threads: 12; BS: Windows 10.0; UI-Render: GL; Gebietsschema: de-DE (de_DE); Calc: CL, Special devUserProfile

b) With Server Installation of Version:  4.0.0.3 WIN10
Build-ID  7545bee9c2a0782548772a21bc84a9dcc583b89;  Special devUserProfile 
That $-search backwards was completely broken.
Comment 6 Justin L 2024-03-15 12:27:43 UTC
repro 24.8+
Comment 7 Justin L 2024-03-15 12:39:05 UTC
Searching for ".$" is revealing...
It works properly in the forward direction (selecting the last character in each paragraph), but for find previous it moves backwards one character at a time (not one paragraph at a time). In other words, in the backwards search, the ending $ seems to just be ignored.
Comment 8 Justin L 2024-03-15 15:02:42 UTC
bug 60259 is a great reference.
+        /* FIXME: this condition does not work for !bSrchForward backward
+         * search, it probably never did. (pSttNd != &rNdIdx.GetNode())
+         * is never true in this case. */
Comment 9 Commit Notification 2024-03-18 13:26:20 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8b58007fc5a619012b58a1f8d8731a753bc1c40d

tdf#147583 sw find: fix backwards search for emptyPara/endOfPara

It will be available in 24.8.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 10 Timur 2024-03-19 12:48:56 UTC
I set Verified for the original issue. 
Issue from comment 7 is a separate one.
Comment 11 Commit Notification 2024-03-21 10:00:13 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

related tdf#147583 sw find: fix backwards search for string at end of para

It will be available in 24.8.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.