Bug 501334

Summary: The KWrite "Find" textfield becomes empty when the user jumps to the next or previous match
Product: [Applications] kate Reporter: funkybomber
Component: kwriteAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: john.kizer
Priority: NOR    
Version First Reported In: 24.12.3   
Target Milestone: ---   
Platform: Flatpak   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Video capture

Description funkybomber 2025-03-11 08:39:37 UTC
SUMMARY

The search functionality in KWrite has a bug that makes the given search string disappear when the user tries to go through the highlighted results.
I think that this bug has appeared in the last couple of minor releases.
This bug has been reproduced in both the official KWrite flatpak (from Flathub) and also in the native Fedora rpm package.

STEPS TO REPRODUCE
1. Open a text file in KWrite
2. Press Ctrl+F to enable the search functionality. The "Find" textfield should now appear at the bottom of the program.
3. Enter a string value to search for.
4. Click on the button "Up" ("Jump to previous match") or the button "Down" ("Jump to next match") next to the textfield.

OBSERVED RESULT
The string disappears from the textfield "Find". This is obviously a bug.

EXPECTED RESULT
The given string should remains in the textfield "Find".

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 41
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.5-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i7-4510U CPU @ 2.00GHz
Memory: 5.7 GiB of RAM
Graphics Processor 1: Mesa Intel® HD Graphics 4400
Graphics Processor 2: llvmpipe
Manufacturer: LENOVO
Product Name: 20351
System Version: Lenovo G50-70
Comment 1 John Kizer 2025-03-26 03:12:45 UTC
Hi - I can't reproduce this bug on Fedora KDE 41, using either the RPM or Flatpak package.

Just to check, are there any messages printed to the console if you run KWrite from a terminal and then trigger the bug?
Comment 2 funkybomber 2025-03-26 11:58:42 UTC
(In reply to John Kizer from comment #1)
> Hi - I can't reproduce this bug on Fedora KDE 41, using either the RPM or
> Flatpak package.
> 
> Just to check, are there any messages printed to the console if you run
> KWrite from a terminal and then trigger the bug?

Hi, thanks for taking an interest in this. I just tested in the latest Flatpak (from Flathub) through the terminal as you asked

running the command "flatpak run org.kde.kwrite" gives me:
libkate.time: All plugins loaded in 0 ms
libkate.time: Created KateMainWindow in 68 ms

(while reproducing the bug nothing appears in the terminal)

Exiting the program gives me:
kf.notifications: Failed to play sound with canberra: Not available
QThreadStorage: Thread 0x556c3a7223a0 exited after QThreadStorage 9 destroyed
Comment 3 funkybomber 2025-03-31 07:24:39 UTC
Created attachment 179880 [details]
Video capture

I have attached a brief video capture that demonstrates the problem.
Comment 4 funkybomber 2025-03-31 07:43:34 UTC
Just for the record I just attempted to downgrade my KWrite flatpak using hashes from prior versions of the program.
To my surprise the bug can be reproduced in older versions also, even though this bug first occurred in my system after an update in early 2025. 

I went as far back as 24.02.0 and it occurs there also.
This makes me suspect that the bug might not be in the KWrite code itself but perhaps in some of its dependencies?
Comment 5 John Kizer 2025-04-01 01:23:54 UTC
Thanks for the video reproduction! Just to check, what steps had taken place before the start of that video to have a blank Find bar already open there?

And, does the issue occur in a newly-created user profile on your device, with no customization applied?
Comment 6 funkybomber 2025-04-01 03:33:54 UTC
(In reply to John Kizer from comment #5)
> Thanks for the video reproduction! Just to check, what steps had taken place
> before the start of that video to have a blank Find bar already open there?
> 
> And, does the issue occur in a newly-created user profile on your device,
> with no customization applied?

Happy to help any way I can!

I open the Find bar with the shortcut: "Ctrl + F"

I just tested with a new user account as you advised and indeed KWrite (flatpak) 24.12.3 is working correctly! Does this still count as a KDE bug? 
Please let me know if there are any other data I can provide. (list of packages, kwrite settings files etc)
Comment 7 John Kizer 2025-04-02 22:10:51 UTC
Ah - well, that gives a lead for investigation! Could you perhaps try incrementally changing your KWrite settings on that new account to match the ones on your existing account? That way, it would hopefully be possible to pin down one that triggers the behavior - hopefully in a way that can then also be reproduced on another device! :-)
Comment 8 funkybomber 2025-04-03 00:48:37 UTC
(In reply to John Kizer from comment #7)
> Ah - well, that gives a lead for investigation! Could you perhaps try
> incrementally changing your KWrite settings on that new account to match the
> ones on your existing account? That way, it would hopefully be possible to
> pin down one that triggers the behavior - hopefully in a way that can then
> also be reproduced on another device! :-)

Good suggestion. I will give it a go when I get some free time.
Comment 9 funkybomber 2025-04-05 00:30:11 UTC
Progress! I have been able to narrow it down considerably.

I used KDiff3 to compare my custom kwriterc and the default one.

I kept a backup of the original and I started adding my custom sections of the kwriterc one by one to see after which one I would be able to trigger the bug.

I was able to reproduce the bug right after I added the following segment to kwriterc:

[KTextEditor::Search]
Replace History=
Search History=     <--- This is the culprit I think. Has this been deprecated perhaps?

After I triggered the error I tried to delete this segment from kwriterc and to my surprise after I relaunched KWrite the bug persisted.

I was able to resolve the bug when I restored my initial backup of kwriterc.

I will attach my custom kwriterc just in case it is useful:


# my custom settings for KWrite

[General]
Allow Tab Scrolling=true
Auto Hide Tabs=false
Close After Last=true
Close documents with window=true
Cycle To First Tab=true
Days Meta Infos=30
Diagnostics Limit=12000
Diff Show Style=0
Elide Tab Text=false
Enable Context ToolView=false
Expand Tabs=false
Modified Notification=false
Mouse back button action=0
Mouse forward button action=0
Open New Tab To The Right Of Current=false
Output With Date=false
Recent File List Entry Count=10
Restore Window Configuration=true
SDI Mode=false
Save Meta Infos=true
Show Full Path in Title=true
Show Menu Bar=true
Show Status Bar=true
Show Symbol In Navigation Bar=true
Show Tab Bar=true
Show Tabs Close Button=true
Show Url Nav Bar=true
Show welcome view for new window=true
Startup Session=manual
Stash new unsaved files=true
Stash unsaved file changes=false
Tab Double Click New Document=true
Tab Middle Click Close Document=true
Tabbar Tab Limit=0

[KTextEditor Document]
Allow End of Line Detection=true
Auto Detect Indent=true
Auto Reload If State Is In Version Control=true
Auto Save=false
Auto Save Interval=0
Auto Save On Focus Out=false
BOM=false
Backup Local=false
Backup Prefix=
Backup Remote=false
Backup Suffix=~
Camel Cursor=true
Encoding=UTF-8
End of Line=0
Indent On Backspace=true
Indent On Tab=true
Indent On Text Paste=true
Indentation Mode=normal
Indentation Width=4
Keep Extra Spaces=false
Line Length Limit=10000
Newline at End of File=true
On-The-Fly Spellcheck=false
Overwrite Mode=false
PageUp/PageDown Moves Cursor=false
Remove Spaces=1
ReplaceTabsDyn=true
Show Spaces=0
Show Tabs=true
Smart Home=true
Swap Directory=
Swap File Mode=1
Swap Sync Interval=15
Tab Handling=2
Tab Width=4
Trailing Marker Size=1
Use Editor Config=true
Word Wrap=false
Word Wrap Column=80

[KTextEditor Renderer]
Animate Bracket Matching=false
Auto Color Theme Selection=false
Color Theme=Funky KWrite theme
Line Height Multiplier=1
Show Indentation Lines=true
Show Whole Bracket Expression=false
Text Font=Noto Sans Mono Medium,10,-1,5,500,0,0,0,0,0,0,0,0,0,0,1,Regular
Text Font Features=
Word Wrap Marker=false

[KTextEditor View]
Allow Mark Menu=true
Auto Brackets=false
Auto Center Lines=0
Auto Completion=false
Auto Completion Preselect First Entry=true
Backspace Remove Composed Characters=false
Bookmark Menu Sorting=0
Bracket Match Preview=true
Chars To Enclose Selection=<>(){}[]'"
Default Mark Type=1
Dynamic Word Wrap=true
Dynamic Word Wrap Align Indent=80
Dynamic Word Wrap At Static Marker=false
Dynamic Word Wrap Indicators=1
Dynamic Wrap not at word boundaries=false
Enable Accessibility=true
Enable Tab completion=false
Enter To Insert Completion=true
Fold First Line=false
Folding Bar=true
Folding Preview=true
Icon Bar=false
Input Mode=0
Keyword Completion=true
Line Modification=true
Line Numbers=true
Max Clipboard History Entries=3
Maximum Search History Size=0
Mouse Paste At Cursor Position=false
Multiple Cursor Modifier=134217728
Persistent Selection=false
Scroll Bar Marks=false
Scroll Bar Mini Map All=true
Scroll Bar Mini Map Width=60
Scroll Bar MiniMap=true
Scroll Bar Preview=true
Scroll Past End=true
Search/Replace Flags=140
Shoe Line Ending Type in Statusbar=false
Show Documentation With Completion=true
Show File Encoding=true
Show Folding Icons On Hover Only=true
Show Line Count=false
Show Scrollbars=0
Show Statusbar Dictionary=true
Show Statusbar Highlighting Mode=true
Show Statusbar Input Mode=true
Show Statusbar Line Column=true
Show Statusbar Tab Settings=true
Show Word Count=false
Smart Copy Cut=true
Statusbar Line Column Compact Mode=true
Text Drag And Drop=true
User Sets Of Chars To Enclose Selection=
Vi Input Mode Steal Keys=false
Vi Relative Line Numbers=false
Word Completion=true
Word Completion Minimal Word Length=3
Word Completion Remove Tail=true

[KTextEditor::Search]
Replace History=
Search History=

[MainWindow]
1366x768 screen: Height=507
1366x768 screen: Width=814
1366x768 screen: Window-Maximized=true
ToolBarsMovable=Disabled

[MainWindow][Toolbar mainToolBar]
IconSize=16

[UiSettings]
ColorScheme=
Comment 10 John Kizer 2025-04-06 04:15:02 UTC
Nice catch! Do you happen to know how that [KTextEditor::Search] section was added to your original kwriterc? I'm just checking as neither the Fedora RPM nor Flatpak versions that I have installed have that section present, so I just wanted to check before chalking things up to a local device issue :-)

Thanks!
Comment 11 funkybomber 2025-04-08 10:09:25 UTC
After some testing I have to admit that this was probably user error.
I think I had added this section manually inside kwriterc in an effort to remove the history of searches from the "Find" field.
The proper location for this segment seems to be this one instead:
/home/funky/.var/app/org.kde.kwrite/.local/state/kwritestaterc

Sorry for wasting your time. I'll mark this one as resolved.
It would be nice to have an easy way to remove the history of searches from the "Find" field btw! Privacy and all...
Comment 12 John Kizer 2025-04-08 13:12:16 UTC
(In reply to funkybomber from comment #11)
> It would be nice to have an easy way to remove the history of searches from
> the "Find" field btw! Privacy and all...

Sounds like a good feature request - which can be submitted as a bug report here, with "wishlist" as the severity level :-)