Bug 327408 - Replace in a selected text does not work well after the first match by the button Next
Summary: Replace in a selected text does not work well after the first match by the bu...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 413182 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-11-10 13:20 UTC by dalves31
Modified: 2021-04-15 07:39 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.82.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dalves31 2013-11-10 13:20:36 UTC
When using replace (Ctrl+r), with a selected text, after pressing Next and the first match is found, pressing Next again will have no effect. It seems that Kdevelop changes the selected text to the first match and restrict its search to that selected string (therefore, pressing Next wouldn't find anything). For example, for a code like the following:

#include <boost/format.hpp>
#include "lineartriangle.h"
#include "launchError.h"
#include "macros.h"

If we select only the first 3 lines and select and tick "Selection only" and search for "include" using "Next" in the command Replace, the "include" in the first line will be highlighted. However, pressing next again will continue to highlight that word. Pressing Replace and Next will replace the word, but Next will still have no effect.

Reproducible: Always

Steps to Reproduce:
1.Call Replace (Ctrl+r)
2.Select a portion of the text and tick Selection only
3.Press Next 2 times.
Actual Results:  
Kdevelop selects the first match and can't find any other match.

Expected Results:  
Kdevelop should find the next match.
Comment 1 Andrew Crouthamel 2018-11-10 03:13:02 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 2 Andrew Crouthamel 2018-11-20 03:59:17 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Rolf Eike Beer 2018-11-20 13:29:02 UTC
Still seen in current master.
Comment 4 Kevin Funk 2018-11-20 13:32:25 UTC
This looks like a KTextEditor bug to me. I can reproduce the issue in Kate.
Comment 5 Christoph Cullmann 2021-04-08 19:55:29 UTC
Git commit ebe04f38d868503fdb9a2061665159768a5479b2 by Christoph Cullmann, on behalf of Jan Paul Batrina.
Committed on 08/04/2021 at 19:55.
Pushed by cullmann into branch 'master'.

Fix incremental selection-only search

Since search matches are selected after they are found,
the "Search in selection only" option only works the first time.

This patch saves the initial selection where the search is initiated
and use that for succeeding selection-only searches. The selection
is "forgotten" only after the selection is manually changed or
the "selection only" option is toggled.

M  +18   -2    autotests/src/searchbar_test.cpp
M  +30   -14   src/search/katesearchbar.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/ebe04f38d868503fdb9a2061665159768a5479b2
Comment 6 Jan Paul Batrina 2021-04-15 07:39:54 UTC
*** Bug 413182 has been marked as a duplicate of this bug. ***