Open RheingoldRiver opened 5 years ago
most likely you are running into https://github.com/SublimeTextIssues/Core/issues/1262 as opposed to a problem in the Lua indentation rules
Ah yeah sounds like that
As end
keyword is a custom one, which needs to be handled via tmPreferences
I rather think it's a bug in the Indent.tmPreference
A very quick and lazy check revealed the following changed file (removed some \b
) to fix the issue for end
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Indent</string>
<key>scope</key>
<string>source.lua</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>(^\s*(elsei|elseif|else|end|until)\b.*$|^((?!\{).)*\}\;?.*$)</string>
<key>increaseIndentPattern</key>
<string>(^\s*((local[\s\w=]+)?function|repeat|else|elseif|if|while)\b((?!\bend\b).)*$|^.*\b(do|then)\b((?!\bend\b).)*$|^.*\{((?!\}).)*$)</string>
</dict>
</dict>
</plist>
... but there may be more.
SublimeTextIssues/Core#1262 is just about the "hardcoded" indention rules applied to {
and }
.
Interesting ... maybe indeed triggering the core issue sometimes.
See how dedenting the keyword end
works or fails depending on whether an end was added to the function declaration line before or not.
Content of Packages/Lua/Indent.tmPreferences
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Indent</string>
<key>scope</key>
<string>source.lua</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>(?x:
^\s*(
(elsei|elseif|else|end|until)\b
|
((?!\{).)??\}\;?
).*?$
)</string>
<key>increaseIndentPattern</key>
<string>(?x:
^\s*(
((local[\s\w=]+)?function|repeat|else|elseif|if|while)\b((?!\bend\b).)*?
|
.*?\b(do|then)\b((?!\bend\b).)*?
|
.*?\{((?!\}).)*?
)$
)</string>
</dict>
</dict>
</plist>
screenshot -
code from screenshot -
Or to recreate, type this at the start of an empty document:
I think the 2nd end should also be returned to the start of the line in this case