sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

Problem disabling package #208

Closed jsolisu closed 5 years ago

jsolisu commented 6 years ago

When the package is disabled, the event subscription to ActivePaneItem is not unsubscribed.

// Hook into the events to recognize the user opening new editors or changing the pane
const activate = () => {
    generateConfig();
    showState();
    fixFile();
    atom.workspace.observeTextEditors(observeTextEditor);
    /* This subscription */ atom.workspace.observeActivePaneItem(observeActivePaneItem);
    reapplyEditorconfig();
};

// Clean the status-icon up, remove all embedded editorconfig-objects
const deactivate = () => {
    const textEditors = atom.workspace.getTextEditors();
    textEditors.forEach(editor => {
        editor.getBuffer().editorconfig.disposables.dispose();
    });
    statusTile.removeIcon();
};

Maybe the solution is to use a variable to receive the result of observeActivePaneItem and call dispose() to unsubscribe when package is disabled.

florianb commented 6 years ago

Thanks for reporting @jsolisu - the whole package is under a rewrite. If you can't wait this being fixed, i'd be happy to accept a PR! :)