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

Fix onDidSave event handling #28

Closed
wants to merge 2 commits into from

Conversation

mgoggin
Copy link

@mgoggin mgoggin commented Dec 12, 2022

When the extension is activated on an empty workspace, nova.workspace.activeTextEditor is undefined which raises an unhandled exception.

Instead, add an onDidAddTextEditor event handler to the workspace and add onDidSave to the new TextEditor instance.

We also clean up event handlers on extension deactivation.

Fixes #27

When the extension is activated on an empty workspace, `nova.workspace.activeTextEditor` is `undefined` which raises an unhandled exception.

Instead, add an `onDidAddTextEditor` event handler to the workspace and add `onDidSave` to the new `TextEditor` instance.
When the extension is deactivated (or reloaded), we dispose of registered event handlers.

This fixes an issue where `onDidSave` would be called twice when a file was reopened and saved after the extension was reloaded.
@tommasongr
Copy link
Collaborator

Thanks! I'll review it asap

@eirvandelden
Copy link
Contributor

@tommasongr Can you look at this PR? the unhandled exception is still being raised in nova-rails extension.

Locally I'm already using your solar graph extension, and using these 2 extensions side by side works great 👍

@tommasongr
Copy link
Collaborator

Hi @eirvandelden, I'm sorry if I've not been active recently but I'm currently a bit busy with other work stuff.

I'll try to take a look at this and other open issues as soon as I can ☺️

@mgoggin mgoggin closed this Oct 10, 2023
@mgoggin mgoggin deleted the fix-onDidSave-event-handling branch October 10, 2023 20:27
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

Successfully merging this pull request may close these issues.

Error using Rubocop
3 participants