bcomnes / sublime-standard-format

:sparkles: Runs standard --fix against the javascript in your ST3 window on save or manually.
https://packagecontrol.io/packages/StandardFormat
MIT License
60 stars 21 forks source link

Project -> Refresh Folders causes StandardFormat to crash (causing the refresh to fail) #73

Closed stiang closed 4 years ago

stiang commented 4 years ago

My dev files reside on a Linux server which I have NFS mounted on my Mac (10.15.4) to /some/local/path.

Since file watching doesn’t work (reliably) over NFS I have to use the ST command Project -> Refresh Folders whenever new files are added. This is no problem in itself, but I’ve discovered that StandardFormatter apparently causes that command to fail. Here’s what I see in the console:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 627, in on_activated_async
    callback.on_activated_async(v)
  File "/Users/stian/Library/Application Support/Sublime Text 3/Installed Packages/StandardFormat.sublime-package/standard-format.py", line 151, in on_activated_async
    search_path = generate_search_path(view)
  File "/Users/stian/Library/Application Support/Sublime Text 3/Installed Packages/StandardFormat.sublime-package/standard-format.py", line 89, in generate_search_path
    search_path = search_path + [get_project_path(view)]
  File "/Users/stian/Library/Application Support/Sublime Text 3/Installed Packages/StandardFormat.sublime-package/standard-format.py", line 67, in get_project_path
    parent_window_folders = view.window().folders()
AttributeError: 'NoneType' object has no attribute 'folders'

Would this be easy to fix? It’s causing me some real issues, since I don’t always see all the files in a project (sometimes even without knowing about it). It appears that this can happen even when ST itself scans the folders, not just when I do it manually.

StandardFormat version: 6.2.0 ST version: 3.2.2 (build 3211)

bcomnes commented 4 years ago

I can take a look. Easiest workaround is to work with a real drive for now. It shouldn’t fail like that though so at a minimum we should gracefully fail if something goes wrong.

stiang commented 4 years ago

Thanks, it would be great if you could take a look, since my workflow is based entirely on NFS-mounted disks now. The only workable workaround for me would be to disable StandardFormat, which I hope I won’t have to do :)

bcomnes commented 4 years ago

Ok, I have a PR https://github.com/bcomnes/sublime-standard-format/pull/74 that should handle this case a little bit better. Let me get that released today, and after a few hours, sublime's package registry should pick it up.

bcomnes commented 4 years ago

Give it a whirl when the plugin updates to 6.2.1. Could be other broken assumptions. Sounds like sublime's API contract is different on NFS mounts.