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

Run fix in some sort of background thread? #24

Open
IPWright83 opened this issue Jan 25, 2021 · 7 comments
Open

Run fix in some sort of background thread? #24

IPWright83 opened this issue Jan 25, 2021 · 7 comments

Comments

@IPWright83
Copy link

I've tried enabling the fix_on_save flag today, which is really great, but it massively slows down the editing experience. Sublime locks for somewhere between 1-2 seconds while it processes this.

Is there anyway that this can be ran in some sort of background thread so Sublime remains responsive through this duration?

@sindresorhus
Copy link
Member

I think

def on_pre_save(self, view):
could use on_pre_save_async instead. But I haven't tested.

https://www.sublimetext.com/docs/3/api_reference.html

// @LuKks

@IPWright83
Copy link
Author

@sindresorhus looks promising! I'm happy to give it a test on my project if someone can publish some sort of pre-release

@IPWright83
Copy link
Author

@sindresorhus is there a way I can try this out? I've tried modifying the linter.py file inside /home/.config/sublime-text-3/installed packages/SublimeLinter-contrib-xo.sublime-package. Is that the correct way to try and test? At the moment doesn't look like it's working

@IPWright83
Copy link
Author

IPWright83 commented May 12, 2021

Ok, confirmed that the change has been made with some logging, unfortunately it doesn't seem to fix the locking issue :( . Been trying to compare to the prettier plugin which does similar stuff but don't yet understand python well enough to spot the difference.

@LuKks
Copy link
Contributor

LuKks commented May 12, 2021

I tried just changing to on_pre_save_async but works the same (sync), I think we need some code related to threading in Python to make it really async, for example running xo_fix function in another thread.

@rocktimsaikia
Copy link

Hi @IPWright83, did you find any solution to this issue?

@IPWright83
Copy link
Author

@rocktimsaikia I didn't. Though I've moved company and we just use eslint. It doesn't seem to have the same problems as the xo linter. Save in build seems to work fine without blocking.

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

4 participants