Bug 468409

Summary: Kate should not show an extra new line at the end of files
Product: [Applications] kate Reporter: Synthetic451 <bugs.kde.org.facelift226>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: christoph
Priority: NOR    
Version First Reported In: 22.12.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Picture of extra line in vs code

Description Synthetic451 2023-04-12 01:21:39 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
Kate seems to add an extra new line to text files when **opening** them. This gives users a false impression of how many lines are actually in the text file. Please note, I am not talking about the "Append newline at end of file on save" option, which I have already disabled. This is about new lines being added upon opening.

Please add an option to disable this "feature" or at the very least make the line counter for that last line have a lighter color, which is what I think Visual Studio Code does to indicate that it isn't a real line in the file.

STEPS TO REPRODUCE
1. Create a text file with, lets say, 5 lines of text using vim.
2. Open the file in Kate.

OBSERVED RESULT
6 lines of text are shown in Kate

EXPECTED RESULT
5 lines of text should be shown in Kate, or at the very least that 6th added line should have a different, lighter color in the line counter text.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
Comment 1 Christoph Cullmann 2023-04-12 07:35:35 UTC
That is no bug, vim per default adds a trailing \n, therefore the file has 6 lines.
Comment 2 Synthetic451 2023-04-12 09:03:00 UTC
Why does vim only show 5 lines when reopening the file then? In vim, I can not move the caret onto the 6th line, but in Kate I can.
Comment 3 Christoph Cullmann 2023-04-12 09:05:22 UTC
(In reply to Benjamin Xiao from comment #2)
> Why does vim only show 5 lines when reopening the file then? In vim, I can
> not move the caret onto the 6th line, but in Kate I can.

Because vim handles that differently, try e.g. mcedit, it will show 6 lines, too.
Comment 4 Christoph Cullmann 2023-04-12 09:07:13 UTC
And just as a side note, e.g. Atom or Code handle this like we do, too.
Comment 5 Synthetic451 2023-04-12 09:11:36 UTC
Created attachment 158029 [details]
Picture of extra line in vs code

Yes, I did notice this in Code already, but the difference is that the line counter is slightly grayed out to indicate that it isn't an actual line in the file. See the attachment.

I think this could be a nice enhancement to Kate to indicate that there isn't an extra blank line in the file.
Comment 6 Christoph Cullmann 2023-04-12 10:21:52 UTC
(In reply to Benjamin Xiao from comment #5)
> Created attachment 158029 [details]
> Picture of extra line in vs code
> 
> Yes, I did notice this in Code already, but the difference is that the line
> counter is slightly grayed out to indicate that it isn't an actual line in
> the file. See the attachment.
> 
> I think this could be a nice enhancement to Kate to indicate that there
> isn't an extra blank line in the file.

But it is some extra line.
That would just mean the last empty line is always highlighted, I fail to see why that make any sense, sorry.