This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Tune behavior of ignore whitespace on current line #169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Fix #76
Description of the Change
Previously
ignoreWhitespaceOnCurrentLine
was not appropriately respected when one buffer is opened in multiple editors.This PR improve behavior of
ignoreWhitespaceOnCurrentLine
how most user expect(I believe so).In case test case's intention was not clear, see following illustration what happens on save.
Condition
When two editor open same file. Two editor shares same buffer.
|
represent cursor_
represent trailing white spacescase 1: saved when editor1 is active
result: editor1's cursor line was excluded
case 2: saved when editor2 is active
result: editor2's cursor line was excluded
case 3: saved when either editor1 nor editor2 was active
This situation happens when
Window: Save All
command was fired.result: just removed all trailing spaces
Alternate Designs
Currently same buffer have multiple
buffer.onWillSave
hook.By making this subscription per buffer basis, I think most behavior frustration described in #76 would be fixed.
But as far as I experimented it in my mind, the behavioral result would be same in that case.
So as my understanding making
buffer.onWillSave
subscription to per buffer-basis is kind of refactoring.So not included in this PR.
Benefits
Users are no longer surprised by trailing WS at cursor line is removed in spite of
ignoreWhitespaceOnCurrentLine
istrue
.This was happened when multiple same file is opened in multiple editors.
Possible Drawbacks
None
Applicable Issues
Fix #76