Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code VSCode语法突出显示问题:正向查找不适用于空格_Visual Studio Code_Vscode Extensions_Tmlanguage - Fatal编程技术网

Visual studio code VSCode语法突出显示问题:正向查找不适用于空格

Visual studio code VSCode语法突出显示问题:正向查找不适用于空格,visual-studio-code,vscode-extensions,tmlanguage,Visual Studio Code,Vscode Extensions,Tmlanguage,我正在为VSCode开发一个自定义语言语法突出显示扩展。我遇到了一个问题,lookbehinds在与空白相邻时表现得很奇怪 我想强调的代码示例: variableName :=thisValueShouldHighlight; variableName := thisValueShouldHighlight; variableName := thisValueShouldAlsoHighlight, 我尝试使用的代码示例(在tpl.tmLanguage.json中): “结束变量分配”:{ “

我正在为VSCode开发一个自定义语言语法突出显示扩展。我遇到了一个问题,lookbehinds在与空白相邻时表现得很奇怪

我想强调的代码示例:

variableName :=thisValueShouldHighlight;
variableName := thisValueShouldHighlight;
variableName := thisValueShouldAlsoHighlight,
我尝试使用的代码示例(在
tpl.tmLanguage.json
中):

“结束变量分配”:{
“注释”:“包括结束对变量的赋值。正在进行”,

“匹配”:“(?多亏了@Gama11,我才知道问题出在哪里。另一种模式干扰了第一种模式,但不是以一种对我来说很明显的方式

所讨论的模式是变量赋值的结束部分(实际赋值),因此在使用函数或字符串(如预期)时不适用。它应仅适用于将数字和其他变量的值赋值给所讨论的变量。变量赋值的开始部分(获取变量名并为其赋值)使用单独的块完成

乍一看,我并不认为这是个问题,因为已经包含了另一个模式(
var\u assign
)与
:=
匹配。
开始变量\u赋值
模式的问题在于它与
\\:\\=\\s*
匹配。尾部的
\\s*
就是问题所在。删除它会导致问题再次出现

简言之,以下不同模式的匹配可以和平共存:

":="

"^\\s*(\\w+)\\s*(\\:\\=)"

"(?<=:=)\\s*(\\w+)(;|,)$"
所有这些都是纯粹的观察/测试。很明显,问题在于重叠,可能是可变长度的匹配

tpl 1.15 module Pattern_Module_Name;
pattern Pattern_name 1.0
    triggers
        on si := SoftwareInstace created, confirmed where name matches "(?i)SomeRegex";
    end triggers;
    body
        // RE: STACKOVERFLOW PROBLEM
        // As you can see, these aren't highlighting properly

        var_name :=thisShouldHighlight;
        var_name := thisShouldHighlightButDoesnt;
        var_name := thisShouldHighlightButDoesnt,
    end body;
end pattern;
":="

"^\\s*(\\w+)\\s*(\\:\\=)"

"(?<=:=)\\s*(\\w+)(;|,)$"
"^\\s*(\\w+)\\s*(\\:\\=)\\s*"