Bug 491841

Summary: Duplicated text when formatting Python without a trailing newline
Product: [Applications] kate Reporter: Dragorn421 <dragorn421>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: waqar.17a
Priority: NOR    
Version First Reported In: 23.08.5   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Dragorn421 2024-08-17 22:00:13 UTC
SUMMARY

Code is duplicated when formatting Python source with the last line not being empty


STEPS TO REPRODUCE
1. create a file with content `print ()\na = 1` (where \n stands for a newline) NOTE: no trailing newline, the file should contain exactly those two lines and no empty one at the end
2. run format (Ctrl+T,F by default)
3. the file is now `a = 1\nprint ()\na = 1` instead of `print()\na = 1\n`

OBSERVED RESULT

Not formatted and with a line having been duplicated:
`a = 1\nprint ()\na = 1`

EXPECTED RESULT

formatted and no duplicate:
`print()\na = 1\n`

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13

ADDITIONAL INFORMATION
-
Comment 1 Waqar Ahmed 2024-08-22 11:57:32 UTC
This was fixed long ago. Please update to version 24.05 or later