jcberquist / sublimetext-cfml

CFML (ColdFusion and Lucee) package for Sublime Text
MIT License
115 stars 24 forks source link

Improper auto-indent for closing tags #106

Closed redtopia closed 6 years ago

redtopia commented 6 years ago

Not sure if this is an issue with the sublimetext-cfml package, but I'm having an issue that's been around forever that incorrectly alters the indent of a close tag by moving it to the left by one tab. Here's a screenshot:

indent

jcberquist commented 6 years ago

Have you noticed that with any tags besides <cfscript>? I can play around with it; I suspect part of the issue with it is that there are different indent rules for tags and script, and the context switches inside the body of the <cfscript> tag.

redtopia commented 6 years ago

Thanks for looking into it... it only seems to be happening with <cfscript>

redtopia commented 6 years ago

I noticed you closed this, but I have not tried the most recent build. Just wanted to show you that it's not only happening with cfscript. Here's another example:

xfbita7p42

jcberquist commented 6 years ago

Unfortunately I don't think your latest example is fixable just by adjusting the ST indent rules. ST increases and decreases indent based on a regex test of the current or preceding line. It does not do anything as sophisticated as look back to the indent level of an opening tag. So, simply put, the increase indent rule says indent one level after an opening tag; and the decrease indent rule says decrease indent one level when a closing tag is the first thing on a line.

I wanted to change the <cfscript> tag specifically because it doesn't actually indent after the opening tag (due to the switch from tags to script I think) and so I thought it didn't make sense for it to decrease the indent at the closing tag. In the case of <cfoutput> it does actually increase the indent level after it, and so the closing </cfoutput> tag has a corresponding decrease indent.

If you are not indenting inside of the <cfoutput> tags you might want to create your own indent rules by overriding this file: cfml-indent.tmPreferences in your User package folder.