Bug 447153

Summary: Kate ignores the "Remove trailing spaces" being "On Modified Lines" when an .editorconfig is present
Product: [Applications] kate Reporter: Nikos Chantziaras <realnc>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: wishlist CC: christoph, waqar.17a
Priority: NOR    
Version First Reported In: 21.12.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nikos Chantziaras 2021-12-18 00:29:08 UTC
SUMMARY
***
When editing a file in a project that ships an .editorconfig file with:

trim_trailing_whitespace = true

in it, then Kate will ignore that I have set the "Remove Trailing Spaces" option to "On Modified Lines." As a result, when I save the file and then do "git add" and "git commit", there can be dozens of even hundreds of modified lines even though I only touched one or two lines.

This currently makes Kate completely unusable in such projects.
***


STEPS TO REPRODUCE
1. Create an .editorconfig with:

  [*]
  trim_trailing_whitespace = true

in it.

2. Create a text file with lots of lines and spaces at the end of the lines.
3. In Settings->Configure Kate->Open/Save, set "Remove Trailing Spaces" to "On Modified Lines."
4. Edit that file with kate and only change one line, then save.

OBSERVED RESULT
The whole file is modified.

EXPECTED RESULT
Only changed lines should be modified.

SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 2.8
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.2
Kernel Version: 5.10.87-gentoo (64-bit)
Graphics Platform: X11
Comment 1 Waqar Ahmed 2022-01-21 21:36:02 UTC
Hi, I think this is working as intended.

We have to respect the editorconfig and do exactly what it says otherwise there is no point in having the editorconfig file.

To resolve this, the editorconfig must add another option to "Remove trailing spaces on modified lines only"
Comment 2 Nikos Chantziaras 2022-01-21 21:48:59 UTC
(In reply to Waqar Ahmed from comment #1)
> We have to respect the editorconfig and do exactly what it says otherwise
> there is no point in having the editorconfig file.

I believe it's up to me whether or not I want to respect the editorconfig file. I mean, I'm the one writing the code, the decision is up to me :P My only options right now is to either drive myself insane with all these changed lines and then jump off a bridge when I can't take it anymore, or use another editor, which would really suck because Kate is great.


> To resolve this, the editorconfig must add another option to "Remove
> trailing spaces on modified lines only"

I don't think there is such an option?
Comment 3 Waqar Ahmed 2022-01-21 22:25:48 UTC
You have another option. As you said it's up to you, you can remove that setting from the editorconfig and then Kate will respect your settings. 

In practice there shouldn't be any spaces in the first place or not a setting in the config if you want spaces to be preserved. The only way spaces would end up in files would be that someone used an editor which didn't respect editorconfig which again defeats the point of having that config. 

Also I closed the issue because there is no way forward with this. We cannot not respect editorconfig. Reopening doesn't change that.
Comment 4 Nikos Chantziaras 2022-01-21 22:34:57 UTC
(In reply to Waqar Ahmed from comment #3)
> You have another option. As you said it's up to you, you can remove that
> setting from the editorconfig and then Kate will respect your settings. 

It' not my project. I just contribute to it. I didn't put the editorconfig in it.


> In practice there shouldn't be any spaces in the first place or not a
> setting in the config if you want spaces to be preserved. The only way
> spaces would end up in files would be that someone used an editor which
> didn't respect editorconfig which again defeats the point of having that
> config. 

Yeah. So I would like to ignore it.


> Also I closed the issue because there is no way forward with this. We cannot
> not respect editorconfig. Reopening doesn't change that.

Why can you not not respect editorconfig? I don't get it. Is it a law and you have to respect it? Would you get sued if you had an option to either ignore it, or leave the interpretation of "clean spaces" up to the user?
Comment 5 Christoph Cullmann 2022-01-22 18:58:03 UTC
First I must say: no, respecting the file is correct.
If you don't want that style either edit it or argue with the people that want that style in that project, if it is not the style you would like.

Beside this, perhaps it would make sense to have some option to disable the loading of both .editorconfig and .kateconfig files.
But that is nothing high up in my priority list.
Comment 6 Waqar Ahmed 2022-08-12 12:32:28 UTC
For alternate solutions mentioned by Christoph, feel free to open a new bug report. 

Right now its working as intended.