jdavisclark / JsFormat

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

Fix indent when formatting empty files #122

Closed robinjmurphy closed 9 years ago

robinjmurphy commented 9 years ago

JsFormat currently overrides the Indent Using Spaces setting when formatting empty files. This is a problem when format_on_save is enabled as it forces all new Javascript files to use tabs for indents. To reproduce the bug:

  1. Create an empty file and save it with a .js extension
  2. Enable the Indent Using Spaces setting in the bottom right corner of the Sublime window
  3. Format the file using JsFormat (ctrl + option + f)
  4. The Indent Using Spaces setting is overwritten

This is happening because:

This PR fixes this by ensuring merge_code returns before forcing tabs if the file is empty