vscode编辑VBA扩展 XVBA - Live Server VBA 代码格式化 自动缩进错误问题修复

XVBA - Live Server VBA  v4.0.26版本中,代码格式化时,发现以下问题:

  1. next后面没有字符的时候,不能识别为末行
  2. if then 后面加逻辑单独作为一行时,错误的识别为开始行

解决办法:

找到插件目录(我的是C:\Users\Administrator\.vscode\extensions\local-smart.excel-live-server-4.0.26\dist)中的

bundle.js,用vscode格式化代码,然后编辑修改相应行(我的是14730开始),重新启动vscode,完成!

l = [
                { type: "function", regex: /(?<=sub |function )(.*?)(?=\s*\()/i, indent: "init" },
                { type: "If Then", regex: /^ *If(?!.+Then.+)/i, indent: "start" },
                { type: "Else", regex: /^( *Else)/i, indent: "mid" },
                { type: "End If", regex: /^( *End)(\s)(If)/i, indent: "end" },
                { type: "End Sub", regex: /^( *End)(\s)(Sub|Function)/i, indent: "close" },
                { type: "Do While", regex: /^( *Do) +While/i, indent: "start" },
                { type: "Loop", regex: /^( *Loop)((?!.*).)*$/i, indent: "end" },
                { type: "For Each", regex: /^( *For)(\s)(Each)(.*)/i, indent: "start" },
                { type: "For To", regex: /^( *For)(.*)(to)(.*)/i, indent: "start" },
                { type: "Next", regex: /^( *Next)(.*)/i, indent: "end" },
                { type: "Do Until", regex: /^( *Do)(\s)(Until)(.*)/i, indent: "start" },
                { type: "Do", regex: /^( *Do)((?!.*).)*$/i, indent: "start" },
                { type: "Loop While", regex: /^( *Loop)(\s)(While)(.*)/i, indent: "end" },
                { type: "Loop Until", regex: /^( *Loop)(\s)(Until)(.*)/i, indent: "end" },
                { type: "Select Case", regex: /^( *Select)(\s)(Case)(.*)/i, indent: "start" },
                { type: "Case", regex: /^( *Case)(\s)(.*)/i, indent: "mid+" },
                { type: "End Select", regex: /^( *End)(\s)(Select)/i, indent: "end" },
                { type: "While", regex: /^( *While)(\s)(.*)/i, indent: "start" },
                { type: "Wend", regex: /^( *Wend)/i, indent: "end" },
                { type: "With", regex: /^ *With/i, indent: "start" },
                { type: "End With", regex: /^ *End\s*With/i, indent: "end" },
            ],

 

posted @ 2023-03-02 12:53  老小鱼  阅读(1744)  评论(0编辑  收藏  举报