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

Removing of trailing whitespace happens for selected lines, not all lines #57

Open
alankilborn opened this issue Oct 28, 2024 · 6 comments

Comments

@alankilborn
Copy link

A change was introduced, I believe it was in Notepad++ 8.4.9, that causes its command for "Trim Trailing Space" to only do that operation on selected text lines (if some selection is active at the time the command is executed), not on the entire file (as was behavior before 8.4.9).

This will cause editorconfig, which I believe invokes that command, to not do the editorconfig "spec" thing when some text is selected at the time of file save. Thus, one could have editorconfig configuration set to remove trailing space, have a selection active, save, and see lines that are not in the selected text region NOT have their trailing whitespace removed.

Using editorconfig for Notepad++ ver 0.4.0.0.

@xuhdev
Copy link
Member

xuhdev commented Oct 29, 2024

Do you have a reference? This kind of drastic API change is a bit unusual...

@alankilborn
Copy link
Author

Reference:

Notepad++ user manual, https://npp-user-manual.org/docs/editing/#edit-menu

image

@ffes
Copy link
Member

ffes commented Nov 3, 2024

Thanks for the reference.

I think cancelling an active selection before saving should do the job. But I haven't look at it in much depth yet.

@alankilborn
Copy link
Author

cancelling an active selection before saving should do the job

It would, but doing it really well would involve:

  • take note of locations and types of active selection(s)
  • invoke SCI_CLEARSELECTIONS
  • restore original selection(s)

That can actually be somewhat complicated.

To me, it would be okay to just cancel any active selections and not worry about restoring them.

@ffes
Copy link
Member

ffes commented Nov 5, 2024

For me, just clearing the selection is the most logical choice. That is just one line of code. And with the possibility in N++ to use multiple selections it indeed could become complicated.

Would you always clear the selection when saving, or just when a trim trailing spaces should be executed?
Me personally, I lean towards always clearing it. This is more consistent and predictable behavior.

@alankilborn
Copy link
Author

IMO always clearing the selection is probably fine.

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

No branches or pull requests

3 participants