Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

jasisk
Copy link

@jasisk jasisk commented Mar 12, 2014

Previously, the whitespace package would bind listeners on buffer events per editor, and unbind when the buffer was destroyed.

The problem is apparent when you use split a pane because, currently, the new copied editor is assigned the same buffer. As a result, if you close one of the editors, the listener is still bound with a reference to an editor that is no longer in your active workspace (because the buffer hasn't been destroyed yet).

This ultimately throws when you call getSelectedBufferRanges on the orphaned editor in ensureSingleTrailingNewline (introduced in dbb992b).

My test is probably pretty bad (getActivePane? :rage4:) but I bounced around dev tools until I learned just enough API to write it so no hard feelings if you :trashcan: it.

Also, make :trashcan: a thing pretty please.

Here's a gif demonstrating the issue:
buffer

Steps to reproduce:

  1. Enable ensureSingleTrailingNewline
  2. Save a file with a trailing new line
  3. Split that file
  4. Close the original editor
  5. Remove trailing newline from the other editor
  6. Attempt to save

@kevinsawicki
Copy link
Contributor

Thanks for this, but I just pushed a fix for it here: 80458b1

@jasisk
Copy link
Author

jasisk commented Mar 12, 2014

@kevinsawicki is a sly dog. Committed as I typed up my PR.

@jasisk jasisk closed this Mar 12, 2014
@jasisk
Copy link
Author

jasisk commented Mar 12, 2014

... and we comment 1 second apart. ✨

@kevinsawicki
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

2 participants