jdavisclark / JsFormat

Javascript formatting for Sublime Text 2 & 3
1.42k stars 222 forks source link

Doesn't work in sublime text #155

Closed kerberw closed 7 years ago

kerberw commented 9 years ago

I can't get the formatter to run though keyboard short cut, menu, or package. It doesn't format for me. It use to work fine until today in Sublime Text 2.

jdavisclark commented 9 years ago

@kerbrew working ok for me on v2.0.2 build 2221 on OSX. Is there any error output in the console?

An update did go out today, but it was pretty localized to the format-on-save feature

kerberw commented 9 years ago

Traceback (most recent call last): File "./sublime_plugin.py", line 185, in on_pre_save File "./sublime_plugin.py", line 154, in run_timed_function File "./sublime_plugin.py", line 184, in File "./js_formatter.py", line 64, in on_pre_save TypeError Writing file /Users/......

kerberw commented 9 years ago

Same version and build you have. OSX El Cap... file path I replaced with (....) ends with with encoding UTF-8

karolyi commented 9 years ago

+1, after the last update, the plugin stopped working.

sublime text 3, osx el capitan.

date of the file js_formatter.py in the package zipfile is Oct 15. you might want to look into this.

the traceback:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 240, in on_pre_save
    callback.on_pre_save(v)
  File "js_formatter in /Users/laszlokarolyi/Library/Application Support/Sublime Text 3/Installed Packages/JsFormat.sublime-package", line 64, in on_pre_save
TypeError

might be connected to what you did here: https://github.com/jdc0589/JsFormat/commit/7dee297869ac5cc825174a3347d0ea475fff57eb

Investigating the issue further, I found that the new(?) option property format_on_save_extensions is looked up at that line, which is missing in the package default configuration. Assigning it in the user configuration fixes the issue.

Please add this property to the default configuration, or assign reasonable defaults in your js_formatter.py when getting this value (as you know a nonexistent key with dict.get returns None if you don't specify any default), hence the TypeError.