Skip to content

Commit dc7bca6

Browse files
committed
optimize indentation rule
1 parent 30c48a6 commit dc7bca6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/languageConfiguration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ export class LuaLanguageConfiguration implements LanguageConfiguration {
5858
}
5959

6060
public indentationRules: IndentationRule = {
61-
// 匹配需要在下一行增加缩进的模式,例如函数定义、局部函数定义和 do 语句
62-
indentNextLinePattern: /^\s*(local\s+\w+\s*=\s*function\s*\(.*\)\s*|function\s+\w*\s*\(.*\)\s*|.*\s*do\s*|.*\s*=\s*function\s*\(.*\)\s*)$/,
61+
// 匹配需要在下一行增加缩进的模式,排除单行结构(如 function() end)
62+
indentNextLinePattern: /^\s*(local\s+\w+\s*=\s*function\s*\(.*\)\s*$|function\s+\w*\s*\(.*\)\s*$|.*\s*do\s*$|.*\s*=\s*function\s*\(.*\)\s*$)/,
6363

6464
// 匹配需要减少缩进的模式,例如 else、elseif 和 end 关键字
6565
decreaseIndentPattern: /^\s*(else|elseif|end|until)\b/,
6666

67-
// 匹配需要增加缩进的模式,例如 function、if、else、elseif、for、while、repeat、until、do 和 then 关键字
68-
increaseIndentPattern: /^\s*(function|local\s+\w+\s*=\s*function|local\s+function|if|else|elseif|for|while|repeat|do|then|.*\s*=\s*function)\b/,
67+
// 匹配需要增加缩进的模式,但排除单行结构(如 function() end, if then else end)
68+
increaseIndentPattern: /^\s*((function\s+\w*\s*\(.*\)\s*$)|(local\s+function\s+\w*\s*\(.*\)\s*$)|(local\s+\w+\s*=\s*function\s*\(.*\)\s*$)|(.*\s*=\s*function\s*\(.*\)\s*$)|(if\s+.*\s+then\s*$)|(elseif\s+.*\s+then\s*$)|(else\s*$)|(for\s+.*\s+do\s*$)|(while\s+.*\s+do\s*$)|(repeat\s*$)|(do\s*$))/,
6969

7070
// 匹配不应改变缩进的模式,例如单行注释和多行注释的结束
7171
unIndentedLinePattern: /^\s*(--.*|.*\*\/)$/

0 commit comments

Comments
 (0)