Bug 490637

Summary: Kate displays newline at the end of file when there isn't
Product: [Applications] kate Reporter: phoenix <felix>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal    
Priority: NOR    
Version First Reported In: 24.05.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description phoenix 2024-07-22 07:23:20 UTC
SUMMARY

Kate displays a newline at the end of a file, even when there isn't one there. This is annoying when editing a yaml file where the linter expects you to have a newline at the end of the file. In kate the editor shows a newline at the end of the file, but the file contents don't have this newline.

The annoying part is that even when adding a newline within kate, kate won't save it. So there is no way to make the yaml linter happy.

The Setting "Append newline at end of file on save" In "Open/Save" does not seem to have an effect.

STEPS TO REPRODUCE

1. Create new file with the following contents:

```yaml
---

key: "value"
```

2. Save the file
3. Kate will add a newline (Line 4) in the display
4. Check the file with any other editor, e.g. `vim`. The immaginary newline is not there
5. `yamllint` will complain about the missing newline

OBSERVED RESULT

* Newline is displayed but not saved
* Enabling/Disabling the "Append newline at end of file on save" does not seem to have any effect on this issue

EXPECTED RESULT

* Newline is only displayed if present
* If present, the newline character at the end of the file will be saved to disk

SOFTWARE/OS VERSIONS

openSUSE Tumbleweed 20240716
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION

None
Comment 1 phoenix 2024-07-22 07:28:30 UTC
Sorry, this report was wrong. The "Append newline at end of file on save" does indeed work, the issue was on the side of a git hook that messed up the file before committing.

Please ignore, Kate behaves just fine :-)