This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
🐛👞 prevents orphaned editor in buffer destroy listener #27
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.
Previously, the whitespace package would bind listeners on
buffer
events pereditor
, and unbind when thebuffer
wasdestroyed
.The problem is apparent when you use split a
pane
because, currently, the new copiededitor
is assigned the samebuffer
. As a result, if you close one of theeditor
s, the listener is still bound with a reference to an editor that is no longer in your activeworkspace
(because thebuffer
hasn't been destroyed yet).This ultimately throws when you call
getSelectedBufferRanges
on the orphanededitor
inensureSingleTrailingNewline
(introduced in dbb992b).My test is probably pretty bad (
) but I bounced around dev tools until I learned just enough API to write it so no hard feelings if you :trashcan: it.
getActivePane
?Also, make :trashcan: a thing pretty please.
Here's a gif demonstrating the issue:
![buffer](https://camo.githubusercontent.com/1242f6e38ae76e83261ccc61b4277dc1e7001d9dcbf1acd2307139332232c6e5/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f36323932332f323339323534352f38363433333562362d613937612d313165332d383930362d3830376630353933336362662e676966)
Steps to reproduce:
ensureSingleTrailingNewline