SublimeLinter-contrib-xo icon indicating copy to clipboard operation
SublimeLinter-contrib-xo copied to clipboard

Run fix in some sort of background thread?

Open IPWright83 opened this issue 4 years ago • 7 comments

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?

IPWright83 avatar Jan 25 '21 10:01 IPWright83

I think https://github.com/xojs/SublimeLinter-contrib-xo/blob/92aa8b3e0d8ac021ce4d34cd7fa9b0cc758b9ed6/linter.py#L172 could use on_pre_save_async instead. But I haven't tested.

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

// @LuKks

sindresorhus avatar Jan 25 '21 11:01 sindresorhus

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

IPWright83 avatar Jan 27 '21 17:01 IPWright83

@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 avatar May 12 '21 11:05 IPWright83

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.

IPWright83 avatar May 12 '21 11:05 IPWright83

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.

LuKks avatar May 12 '21 13:05 LuKks

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

rocktimsaikia avatar Mar 03 '22 08:03 rocktimsaikia

@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.

IPWright83 avatar Mar 09 '22 18:03 IPWright83