microsoft / TypeScript-Sublime-Plugin

IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
Apache License 2.0
1.72k stars 237 forks source link

This plugin breaks "use_tab_stops" option for JS files as well #708

Open kylebebak opened 5 years ago

kylebebak commented 5 years ago

I'm aware this issue is quite nearly a duplicate of #147 , but it's worth creating in any case, because this plugin not only breaks the use_tab_stops setting for the TypeScript syntax... It also breaks it for files with the JavaScript syntax.

As good as the plugin might be, it's really not acceptable that it breaks core Sublime Text functionality for file types it doesn't even work with.

To repro the issue, just create a new view, throw in some JS code:

const a = {
  b: 10,
}

Tab stops still work. As soon as you save the file, e.g. as untitled.js, tab stops stop working.

If you remove the TypeScript plugin, close untitled.js and reopen it, tab stops work again. This behavior was not easy pin down.

kylebebak commented 5 years ago

For anyone interested in fixing this, you need to do two things:

  1. Add "enable_language_service_for_javascript": false, to your User/Preferences.sublime-settings file.

(side note: this setting should definitely not be in User/Preferences.sublime-settings, but rather in User/TypeScript.sublime-settings, because the former file is for settings that apply to all of Sublime Text, not just one package...)

  1. Add "use_tab_stops": true, to User/JavaScript.sublime-settings. For reasons I don't understand this plugin overwrites your JavaScript settings with its own JavaScript.sublime-settings, which means overriding enable_language_service_for_javascript alone isn't enough.

Finally, if you want tab stops to work TypeScript, you have no other option than to use tabs instead of spaces. Create a User/TypeScript.sublime-settings file and add the following:

{
  "translate_tabs_to_spaces": false,
}