Bug 491841 - Duplicated text when formatting Python without a trailing newline
Summary: Duplicated text when formatting Python without a trailing newline
Status: RESOLVED WORKSFORME
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 23.08.5
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-17 22:00 UTC by Dragorn421
Modified: 2024-08-22 11:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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