Sublime Forum

JSON/JS Indenting Broken

#1

I’ve been having this issue for a while but it’s become more of a nuisance recently. It’s two separate issues but likely related.

JS

If I have a very deep level of indentation due to brackets, closures, whatever, upon closing a certain number of these indented blocks Sublime will completely lose the level of indentation its meant to be at and go back to 0. I’ve been trying to replicate it in a sample file but can’t, so it could be something to do with the contents rather than the level of indentation. My only file I have at hand that does it right now is client work so I can’t exactly share it unfortunately. Just hoping someone has had something similar happen.

JSON

This one becomes very apparent in composer.json, where more often than not this happens. As you can see it doesn’t unindent so you end up going further and further indented for no apparent reason. There’s a couple of stray spaces in there but I’ve removed them since I took that shot and nothing changed.

Any thoughts? Running Build 3103 (it happened before I updated though) and my package list is below:

"AdvancedNewFile",
"All Autocomplete",
"ApplySyntax",
"AutoAligner",
"Bootstrap 3 Snippets",
"BracketHighlighter",
"cdnjs",
"Color Highlighter",
"DashDoc",
"Git",
"GitGutter",
"GitGutter-Edge",
"GitHub Flavored Markdown Preview",
"Handlebars",
"HTML5",
"HyperlinkHelper",
"jQuery",
"Laravel Blade Highlighter",
"LESS",
"Markdown Preview",
"Package Control",
"Package Syncing",
"phpfmt",
"Reindent on save",
"Sass",
"SCSS",
"Todo",
"TodoReview"
0 Likes

#2

Maybe the problem is “AutoAligner” or “Reindent on save”. – for js and json I use jsformat package which autoformats the code on save, and works very good.

0 Likes

#3

Tried disabling them with no luck unfortunately.

I did have JsFormat installed, I uninstalled it to see if it was that causing the problem but nope, still got the problem.

0 Likes

#4

Wait, hang on, you may well be right to an extent. I re-installed JsFormat, disabled “Reindent on Save” and it’s indenting properly now. Good spot!

Unfortunately it does mean I don’t have auto-indenting on every file format, but I mostly work in PHP and JS/JSON so having phpfmt and JsFormat going seems to suffice. Cheers!

0 Likes

#5

with reindent_on_save you can enable it using a list of file extensions to reindent https://github.com/mac2000/sublime-reindent-on-save/blob/master/ReindentOnSave.py

"reindent_on_save": ["php", "sublime-settings", "json", "html", "css"]
0 Likes