Bug 453043

Summary: "Replace All" stops before replacing all
Product: [Applications] kate Reporter: arne anka <kde-bugs>
Component: searchAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: waqar.17a
Priority: NOR    
Version: 21.12.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description arne anka 2022-04-26 11:15:17 UTC
SUMMARY
"Find All" and "Replace All" do not consider the same set as "All"

STEPS TO REPRODUCE
1. insert  the string '10, 11, 66, 101, 102, 103, 105, 106, 107, 108, 110, 111, 112, 113, 114, 117, 118, 119, 121, 124, 125, 126, 131, 132, 135, 136, 137, 157, 158, 159, 160, 161, 162, 163, 164, 180, 222, 223, 224, 225, 227, 230, 233, 237, 239, 242, 243, 244, 246, 248, 259, 262, 275, 276, 277, 278, 283, 284, 285, 292, 294, 296, 298, 300, 301, 302, 305, 306, 307, 308, 313, 318, 319, 320, 325, 406, 407, 408, 410, 411, 415, 417, 419, 420, 421, 425, 426, 428, 429, 430, 431, 434, 435, 440, 441, 442, 443, 445, 446'
2. select between10 and 11 the string ", " and hit CTRL+R, insert the string "', '" as replacement (without the double quotes obviously!)
3. select "Plain Text"
4. hit "Find All"
5. literally every occurence is highlighted (note this!)
6. now hit "Replace All"
7. replacement stops halfway through between 308 and 313, no occurence after 313 is replaced, despite "Find All" still highlights those as being exactly the same

OBSERVED RESULT
"Replace All" does not replace all occurences "Find All" finds

EXPECTED RESULT
"Replace All" does replace all occurences "Find All" finds

SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.17.0-1-amd64 (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 5800H with Radeon Graphics
Memory: 31,3 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
Comment 1 arne anka 2022-04-26 11:21:14 UTC
While thinking about it occurs to me that the replacement stops at almost the same position as the original strings ends (493 vs 492).
So, it seems the replacement alogorithm does not take into account that not only the string content but also the string _length_ may change ...
Comment 2 Waqar Ahmed 2022-04-26 12:11:25 UTC
*** This bug has been marked as a duplicate of bug 449767 ***