Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaveAll doesn't apply editorconfig settings to all files being saved #46

Open
alankilborn opened this issue Dec 29, 2022 · 5 comments
Open
Labels

Comments

@alankilborn
Copy link

When executing a "Save All" command in Notepad++, version 0.4.0.0 of the editorconfig plugin doesn't apply its settings to all of the files being saved. Specifically, it will only act upon the currently active file tab if that file needs saving. All of the other (currently inactive) filetabs to be saved will not receive the settings.

It can be demo'd with the attached fileset. Three text files all have trailing whitespace. The editorconfig file indicates that this should be eliminated when saving. Extract all files to a folder and then open the 3 .txt files into Notepad++ which has editorconfig plugin installed. Make a slight change to the first character on line 1 of each of the 3 filetabs, without saving. Make sure test1.txt is the currently active file and invoke File > Save All. Observe that trailing whitespace is eliminated from test1.txt (the active filetab) but although test2.txt and test3.txt are now saved, their trailing whitespace has not been removed.

editorconfig_test.zip

@alankilborn
Copy link
Author

No comments?
Not even some agreement that it appears to be working as I described?

@ffes
Copy link
Member

ffes commented Jul 24, 2024

I can confirm that the problem exists, but I am not sure why yet. The event NPPN_FILEBEFORESAVE is called and handled for every open file but for some reason it doesn't work as expected.

I need to dig into this a bit deeper.

@ffes ffes added the Bug label Jul 24, 2024
@alankilborn
Copy link
Author

The event NPPN_FILEBEFORESAVE is called and handled for every open file but for some reason it doesn't work as expected.

You mean "...for every modified file".

It could be (didn't look really deeply) that you are using Notepad++ commands (e.g. IDM_EDIT_TRIMTRAILING) that act on the active buffer/tab, without making the buffer recevied via NPPN_FILEBEFORESAVE the active buffer first. Making it the active buffer would (obviously) activate the tab, so the Notepad++ UI would change, so you might want to remember which file the user has active when Save All was invoked, and restore it later (so user doesn't wonder why his active tab changed).

@pryrt
Copy link

pryrt commented Oct 28, 2024

Because of this (and other instances of plugins and scripts acting on the active buffer instead of the notification's BufferID for NPPN_FILEBEFORESAVE and similar notifications, the NPP User Manual has been updated to share the best practice for BufferID, and specifically calls it out in the NPPN_FILEBEFORESAVE documentation.

But following that sequence in the Manual is highly recommended for any plugin that implements a callback for NPPN_FILEBEFORESAVE, and especially for any callback that might be used in a Save All circumstance, like in this plugin.

@ffes
Copy link
Member

ffes commented Nov 3, 2024

Thanks for the reference.

This indeed is something that needs to be fixed. I didn't look into it yet, other then reading the comments here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants