Bug 154269 - FindReplaceRememberedSearches not respected in quick find bar
Summary: FindReplaceRememberedSearches not respected in quick find bar
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.5.1.2 release
Hardware: All All
: low minor
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2023-03-19 09:28 UTC by maison
Modified: 2023-04-18 12:23 UTC (History)
5 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 maison 2023-03-19 09:28:05 UTC
Description:
I found and downgraded org.OpenOffice.Office.Common.FindReplaceRembemberdSearches from 10 to 1 in the advanced options.

(The reason is that the current behaviour — where you Ctrl F search for X, then you open the search for Y and close it, then you open it and search for X again and close it; then when you open the search again it’s Y by default because it was the last recorded — breaks my workflow so many times, so I want to work around it. I would like to have by default the item last used, like all current software, not the last recorded in this list.)

Anyway, this setting now remembers the last thing I searched in the the Find and Replace popup (Ctrl H).
However, the bottom search (Ctrl F) doesn’t align with this setting and still uses the last 10 searches.

N.B.: I mainly use Calc, but this problem should be general.

Steps to Reproduce:
1. Set org.OpenOffice.Office.Common.FindReplaceRembemberdSearches = 1
2. Ctrl H, search for X
3. search for Y
4. Look in the drop‐down list for searches: only Y is listed.
5. Close the popup
6. Ctrl F, search for X
7. search for Y
8. Look in the drop‐down list for searches: your last searches are listed.

Actual Results:
In case of Ctrl H FindReplaceRembemberdSearches is used, in case of Ctrl F it is not. Inconsistent.

Expected Results:
The two drop‐down lists should be consistent and respect the FindReplaceRembemberdSearches parameter.


Reproducible: Always


User Profile Reset: No

Additional Info:
Since the « Other information » box is mandatory:
If you have a solution to circumvent the odd behaviour where the search proposes you to reuse the last recorded item in that list, even if in the meantime you reused several other items from the same list, therefore make it reuse the last *used* search item, that would be so useful!
Comment 1 maison 2023-04-03 20:17:52 UTC Comment hidden (obsolete)
Comment 2 Buovjaga 2023-04-06 12:16:46 UTC
Tools - Options - LibreOffice - Advanced - Open Expert Configuration - search for FindReplaceRememberedSearches

Reproduced.

$ git grep -n FindReplaceRememberedSearches
officecfg/registry/data/org/openoffice/Office/Common.xcu:476:    <prop oor:name="FindReplaceRememberedSearches">
officecfg/registry/schema/org/openoffice/Office/Common.xcs:6007:      <prop oor:name="FindReplaceRememberedSearches" oor:type="xs:int" oor:nillable="false">
svx/source/dialog/srchdlg.cxx:345:    nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();

Arch Linux 64-bit, X11
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 79e60bb93f69370f23010adb078b5a5de5a1e7b2
CPU threads: 8; OS: Linux 6.2; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 6 April 2023
Comment 3 Buovjaga 2023-04-06 12:17:43 UTC Comment hidden (obsolete)
Comment 4 V Stuart Foote 2023-04-06 16:51:22 UTC
So your ask is to have the 'FindReplaceRememberedSearches' count from the "Find and Replace" dialog apply to the Find bar? OK.

@Jim, confirm the Find bar list box and Navigator's repeat use does not follow the count if changed, so assume its count is fixed, maybe the default 10? I looked but couldn't find where.

But also the Find bar lb seems a bit chaotic as to entry handling on the list, e.g. which find strings make the lb, both while active, but also on relaunch in current session. 

Can if be made to honor the 'FindReplaceRememberedSearches' setting? But also maybe tighten up the lb logic?
Comment 5 Jim Raykowski 2023-04-07 06:24:40 UTC
(In reply to V Stuart Foote from comment #4)
> @Jim, confirm the Find bar list box and Navigator's repeat use does not
> follow the count if changed, so assume its count is fixed, maybe the default
> 10? I looked but couldn't find where.
svx/source/dialog/srchdlg.cxx
SvxSearchDialog ctor
    //tdf#122322
    nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
    if (nRememberSize<1)
       nRememberSize = 1; //0 crashes with no results found

svx/source/tbxctrls/tbunosearchcontrollers.cxx
FindTextFieldControl::Remember_Impl
    if (nCount == REMEMBER_SIZE)
        m_xWidget->remove(REMEMBER_SIZE-1);
Comment 6 V Stuart Foote 2023-04-07 15:26:28 UTC
(In reply to Jim Raykowski from comment #5)
> svx/source/dialog/srchdlg.cxx
> SvxSearchDialog ctor
>     //tdf#122322
>     nRememberSize =
> officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
>     if (nRememberSize<1)
>        nRememberSize = 1; //0 crashes with no results found
> 
> svx/source/tbxctrls/tbunosearchcontrollers.cxx
> FindTextFieldControl::Remember_Impl
>     if (nCount == REMEMBER_SIZE)
>         m_xWidget->remove(REMEMBER_SIZE-1);

Thanks Jim. 

Both look to use the same FindTextFieldControl() but manage their entries differently.

And the 'Findbar' keeps its REMEMBER_SIZE fixed at 10 [1] when instantiated, and did not get assigned the same nRememberSize for the FindReplaceRememberedSearches handling that the Find and Replace dialog received [2] with some tweaks.

Kind of seems like it should have.  So that the 'Findbar' (also the selector in UI for the string the Navigator uses for repeat) work from the same array/stack of strings the 'Find and Replace' dialog does.

@Heiko?


=-ref-=
[1] https://opengrok.libreoffice.org/xref/core/svx/source/tbxctrls/tbunosearchcontrollers.cxx?a=true&r=9ddbce1e#76
[2] https://gerrit.libreoffice.org/c/core/+/67614/ for bug 122322
Comment 7 Heiko Tietze 2023-04-11 11:03:59 UTC
(In reply to V Stuart Foote from comment #6)
> So that the 'Findbar' (also the selector
> in UI for the string the Navigator uses for repeat) work from the same
> array/stack of strings the 'Find and Replace' dialog does.
Wouldn't expect this but obviously it is the fact. So I agree to apply the REMEMBER_SIZE to the quickfind as well.

(In reply to maison from comment #0)
> I would like to have by default the item last used,
> like all current software, not the last recorded in this list.)
Isn't it how it works. You get the last search entry but can pick one of the n last used from the dropdown. If you search for FOO and BAR on a rotating basis I don't know what program offers the previous search before the last. And I believe it's more common to repeat the last search anyway.
Comment 8 maison 2023-04-11 17:26:11 UTC
(In reply to Heiko Tietze from comment #7)
> 
> (In reply to maison from comment #0)
> > I would like to have by default the item last used,
> > like all current software, not the last recorded in this list.)
> Isn't it how it works. You get the last search entry but can pick one of the
> n last used from the dropdown. If you search for FOO and BAR on a rotating
> basis I don't know what program offers the previous search before the last.
> And I believe it's more common to repeat the last search anyway.

Sorry, your comment shows you still don’t make the distinction between the last recorded and the last used.

Take a big spreadsheet where you want to browse “FindReplaceRememberedSearches not respected in quick find bar” one by one. When you encounter one of them, you realise you temporarily want to look for an occurrence of “abcde”. You did that then you want to go back to your main searches, but now every time you open the quick search bar, Calc stubbornly will want you to search only for abcde. Your main search is nuked and you have to remind it every time; as soon as you select it from the history and use it, close the search bar and open it again, it stubbornly comes back although you don’t want it any more (i.e. because you’ve been using “FindReplaceRememberedSearches not respected in quick find bar”).

This behaviour is inconsistent with Excel (Excel always proposes to reuse the last used search) but also with Calc itself, since if you don’t open the quick search bar, but press Ctrl Shift F, it would indeed reuse the last used search term !
Comment 9 Heiko Tietze 2023-04-12 07:44:32 UTC
(In reply to maison from comment #8)
> “FindReplaceRememberedSearches not respected in quick find bar”

Thought you run into problem with the full search (ctrl+H). Search for 1, the close and reopen and search for 2, close and reopen etc. 1 and 2 alternate and you get the last search. This works as expected, hopefully.

The request is to make the quickfind (ctrl+F) working similarly. It currently does not sort the list if a search item exists. In fact neither the full search does but it remembers the last search item.

Something like 1,2,A,Z should become A,1,2,Z and 2,A,1,Z if you research for A and 2 subsequently. And the first item should be picked on show.

Something for you, Andreas?
Comment 10 V Stuart Foote 2023-04-12 15:57:28 UTC
(In reply to Heiko Tietze from comment #9)
> (In reply to maison from comment #8)
> > “FindReplaceRememberedSearches not respected in quick find bar”
> 
> Thought you run into problem with the full search (ctrl+H). Search for 1,
> the close and reopen and search for 2, close and reopen etc. 1 and 2
> alternate and you get the last search. This works as expected, hopefully.

Unfortunately it does not. That was my "the Find bar lb seems a bit chaotic as to entry handling on the list" from comment 4 ;-)

> 
> The request is to make the quickfind (ctrl+F) working similarly. It
> currently does not sort the list if a search item exists. In fact neither
> the full search does but it remembers the last search item.


I don't think that there is any requirement (nor is it the ask) to sort the entries on the listbox, just that the stack for the lb should *reliably* push the search onto the stack for reuse. The ask is to pare down the stack in response to the nRememberSize set via the  'FindReplaceRememberdSearches' expert config value (either default 10 or as set).
Comment 11 maison 2023-04-12 22:55:24 UTC
(In reply to Heiko Tietze from comment #9)
> Thought you run into problem with the full search (ctrl+H). Search for 1,
> the close and reopen and search for 2, close and reopen etc. 1 and 2
> alternate and you get the last search. This works as expected, hopefully.
> 
> The request is to make the quickfind (ctrl+F) working similarly. It
> currently does not sort the list if a search item exists. In fact neither
> the full search does but it remembers the last search item.
> 
> Something like 1,2,A,Z should become A,1,2,Z and 2,A,1,Z if you research for
> A and 2 subsequently. And the first item should be picked on show.

Indeed, here you point out the problem that the full search popup remembers the last used search, but the quick find toolbar doesn’t. This is another inconsistency between the two searches. I see no reason for the quick search to be stuck to the last recorded item and not reuse the last used item like the other one and it would probably benefit most users; that would be an improvement; it’s just that I didn’t fill an improvement request, but a bug report.

So, if the developer makes the quick search bottom toolbar, the full search & replace popup and Ctrl Shift F coherent with each other, then respect! In that case we would rather describe it in a new bug report.

Otherwise the bare minimum would be IMO that FindReplaceRememberedSearches applies to both search tools.
Comment 12 Andreas Heinisch 2023-04-13 09:54:05 UTC
Proposed patch: https://gerrit.libreoffice.org/c/core/+/150273

Unfortunately, the UI test fails on the clang build and I have no idea why
Comment 13 Andreas Heinisch 2023-04-13 16:11:51 UTC
For the history issue I would prefer a separate report since it can be tested in an UI test. I will submit this patch without the UI test because I have no idea why it fails on the unix clang build.
Comment 14 maison 2023-04-15 09:03:46 UTC
Thanks Andreas.
I created Bug 154818 as an enhancement to pick the last quick find item used.
Contributors are invited to add comments and ideas.
Comment 15 Commit Notification 2023-04-15 09:34:12 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

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

tdf#154269 - Respect FindReplaceRememberedSearches expert option in quick find

It will be available in 7.6.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 16 Commit Notification 2023-04-18 12:21:45 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/11a25339abfb957ea51614b67bbff26cb606f3a2

tdf#154269 - Respect FindReplaceRememberedSearches: add unit test

It will be available in 7.6.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 17 Andreas Heinisch 2023-04-18 12:23:51 UTC
I improved the UI test but it is still not perfect since it does not change the expert option. Somehow the build remembers the old search entries and I don't know how to get rid of it.