Bug 468147 - .editorconfig with trim_trailing_whitespace = true should not apply globally for existing files
Summary: .editorconfig with trim_trailing_whitespace = true should not apply globally ...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 22.12.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-04 12:17 UTC by Buovjaga
Modified: 2023-04-11 05:59 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Buovjaga 2023-04-04 12:17:18 UTC
If you have an .editorconfig file defining

trim_trailing_whitespace = true

Kate will also apply the rule for existing files, trimming all trailing whitespace found in the file. This is not in line with how it is implemented elsewhere:

https://github.com/editorconfig/editorconfig/wiki/FAQ#my-files-are-not-automatically-reformatted-the-editorconfig-plugin-is-not-working

> Existing files are not reformatted by the plugin (only newly input lines are formatted in the format given in the .editorconfig files)

It's true that this is not defined as strictly in the property description, but it seems like a sane way to behave.

https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#trim_trailing_whitespace
Comment 1 Waqar Ahmed 2023-04-04 12:56:31 UTC
IIUC,

it should trim spaces only on lines that are changed and not all lines?
Comment 2 Buovjaga 2023-04-04 13:05:39 UTC
(In reply to Waqar Ahmed from comment #1)
> IIUC,
> 
> it should trim spaces only on lines that are changed and not all lines?

Examples of where I got bitten by this recently:

https://gerrit.libreoffice.org/c/core/+/149627/1/oox/source/export/ooxml-export-notes.txt
https://gerrit.libreoffice.org/c/dictionaries/+/150006/1/en/dialog/en_en_US.properties
Comment 3 Waqar Ahmed 2023-04-04 13:29:26 UTC
ok but you didnt answer my question
Comment 4 Buovjaga 2023-04-04 13:31:45 UTC
(In reply to Waqar Ahmed from comment #3)
> ok but you didnt answer my question

If you meant to ask how the current behaviour should be changed in Kate, then the answer is yes, it should trim spaces only on lines that are changed.
Comment 5 Christoph Cullmann 2023-04-07 15:00:44 UTC
I have no strong opinion on that.
If other editors do that, we could relax the interpretation of this option, too.
Comment 6 Bug Janitor Service 2023-04-07 15:05:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/538
Comment 7 Christoph Cullmann 2023-04-10 18:36:56 UTC
Git commit 94b328fc64e543d91930845d2a96ce08d3043295 by Christoph Cullmann.
Committed on 10/04/2023 at 18:36.
Pushed by cullmann into branch 'master'.

change interpretation of trim_trailing_whitespace

remove trailing spaces of modified lines

M  +1    -1    src/document/editorconfig.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/94b328fc64e543d91930845d2a96ce08d3043295