Bug 510762

Summary: Backwards search starts from the beginning of scrollback rather than end
Product: [Applications] konsole Reporter: bugreporter <somerandomusername234>
Component: historyAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: master   
Target Milestone: ---   
Platform: KDE Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Tentative patch that seems to fix backwards search
Observed behavior: unexpectingly jumps to top of scrollback history
Expected behavior (locally patched): backwards search correctly matches right before cursor

Description bugreporter 2025-10-18 18:06:21 UTC
Created attachment 185885 [details]
Tentative patch that seems to fix backwards search

SUMMARY
Even when the "search backwards" option is enabled (default), searching for a word first jumps to the beginning of scrollback history and then searches backwards from there.

I think this is a bug since it defeats the purpose of backward search. I would expect a backward search to begin from the current prompt (bottom of scrollback history) rather than the top.

STEPS TO REPRODUCE
1. On KDE Linux, or probably other KDE distributions (confirmed on Debian stable), run the following commands in a new Konsole session:

% echo foo
foo
% sudo dmesg | tail -n200
(this is just for filling scrollback history and make the first lines scroll away)
% echo foo
foo

2. Click "Find" or press Ctrl+Shift+F

3. Search for "foo"

OBSERVED RESULT
The first match is near the beginning of scrollback history.

EXPECTED RESULT
The first match should be the last "foo" at the bottom, just before the current prompt, since we are supposed to search backwards.

SOFTWARE/OS VERSIONS
Operating System: KDE Linux 2025-10-18
KDE Plasma Version: 6.5.80
KDE Frameworks Version: 6.20.0
Qt Version: 6.10.0

ADDITIONAL INFORMATION
I can make it work the way I expect by removing the scrollTo(_searchStartLine) call in SessionController::searchTextChanged().

However this call is probably there for a reason, and I haven't studied the Konsole code very well, so it might not be the best way to solve this bug.

So I'm just attaching a sample patch here not as a merge request, but to help actual Konsole devs know where to start looking.
Comment 1 bugreporter 2025-10-19 12:10:01 UTC
Created attachment 185898 [details]
Observed behavior: unexpectingly jumps to top of scrollback history
Comment 2 bugreporter 2025-10-19 12:12:11 UTC
Created attachment 185899 [details]
Expected behavior (locally patched): backwards search correctly matches right before cursor