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

Save on window switch writes fixed import result to other window #24

Open
leoc opened this issue Jul 9, 2018 · 2 comments
Open

Save on window switch writes fixed import result to other window #24

leoc opened this issue Jul 9, 2018 · 2 comments

Comments

@leoc
Copy link

leoc commented Jul 9, 2018

Hi, thanks for this awesome time saving tool!

I configured import-js-fix to be run via after-save-hook. I also have configured a hook that saves the buffer when I am switching to another buffer/window. Sometimes, when I switch to another window, the "fixed code" (of the buffer I was switching away from) is written to the newly selected window buffer.

I will see whether I find time to investigate this week. I suppose a save-excursion and a buffer switch before updating fixed imports would suffice. Maybe you have a quick idea.

Peace & Love

@kevinkehl
Copy link
Collaborator

Hmm yea I see the potential problem here.

I probably won't have time to look too deeply into this until later this week at the earliest, but definitely happy to look at a PR.

Would you mind sharing your code for the buffer switching hook to reproduce?

Just brainstorming some options:

  • Wait to switch until the update is complete (not ideal, since it blocks your flow, and I don't think we want that)
  • Guess the buffer name from the import-js output filename, set the local current buffer before writing data
  • Somehow associate the buffer under operation with the command?

@leoc
Copy link
Author

leoc commented Mar 13, 2019

Hey, I went with the last option as the import-js response does not contain the filename in question. So I hold the buffer filename in a global variable until the response with the resolved imports comes back from the import-js process.

I see a problem there when emacs tries to resolve imports for more than one file. Probably should fill a list of buffers and work through it as the replies come in. But I do not know if import-js daemon works through the requests asynchronously?

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

No branches or pull requests

2 participants