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:
Create an empty file and save it with a .js extension
Enable the Indent Using Spaces setting in the bottom right corner of the Sublime window
Format the file using JsFormat (ctrl + option + f)
The Indent Using Spaces setting is overwritten
This is happening because:
merge_utils.py forces translate_tabs_to_spaces to false (line 68) and later restores it to the user's chosen option (line 83)
However, when there is no code in the file (e.g. a brand new file), the merge_code function returns early before the user's indent preferences have been restored (line 70)
This currently results in translates_tabs_to_spaces being forced to false when saving any empty Javascript file
This PR fixes this by ensuring merge_code returns before forcing tabs if the file is empty
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:.js
extensionctrl
+option
+f
)This is happening because:
merge_utils.py
forcestranslate_tabs_to_spaces
to false (line 68) and later restores it to the user's chosen option (line 83)merge_code
function returns early before the user's indent preferences have been restored (line 70)translates_tabs_to_spaces
being forced tofalse
when saving any empty Javascript fileThis PR fixes this by ensuring
merge_code
returns before forcing tabs if the file is empty