Vscode: In Pascal-like languages begin-end brackets incorrectly match words containing them as parts

Created on 6 May 2017  路  13Comments  路  Source: microsoft/vscode

When defining Pascal-like language, with begin-end brackets, editor thinks, that "begin" and "end" being parts of any other words are also brackets.
I have tried to use regular expression for brackets, however, it seems that regex is not supported there.

match

"language-configuration.json":
lang-conf

  • VSCode Version: 1.12.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Copy any language extension to custom extensions folder
  2. In "language-configuration.json" add "begin-end" brackets
  3. Write in a new file "begin-end" block and "appendElem" function call inside that block
  4. Click on "begin" and see that it matches with function call
editor-bracket-matching feature-request verified

Most helpful comment

In PLSQL language we have delimiters inside others: begin..end but also if...end if

So I need to do something like this:

    "brackets": [
        ["if", "end if"],
        ["loop", "end loop"],
        ["begin", "end"]
    ],

=> It doesn't work with begin...end (it works fine with if...end if and loop...end loop)
image
image

I added character ;

    "brackets": [
        ["if", "end if;"],
        ["loop", "end loop;"],
        ["begin", "end;"]
    ],

=> it doesn't work anymore, nothing is higlighted this time.

All 13 comments

In PLSQL language we have delimiters inside others: begin..end but also if...end if

So I need to do something like this:

    "brackets": [
        ["if", "end if"],
        ["loop", "end loop"],
        ["begin", "end"]
    ],

=> It doesn't work with begin...end (it works fine with if...end if and loop...end loop)
image
image

I added character ;

    "brackets": [
        ["if", "end if;"],
        ["loop", "end loop;"],
        ["begin", "end;"]
    ],

=> it doesn't work anymore, nothing is higlighted this time.

Any progress on this one? Regex support will be ideal, however only checking word boundaries will be already great improvement.

@alexandrudima Thanks! Checked it in Insiders. Working almost great, one minor bug:
If we have two types of brackets which differ only by opening bracket, but closing bracket is same, then in some cases bracket are not highlighted when placing cursor at closing brackets.

Take following configuration:

{
    "comments": {
        "lineComment": "//",
        "blockComment": ["/*", "*/"]
    },
    "brackets": [
        ["(", ")"],
        ["recordbegin", "endrecord"],
        ["simplerecordbegin", "endrecord"]
    ],
    "autoClosingPairs": [
        ["(", ")"],
        ["\"", "\""],
        ["'", "'"]
    ],
    "surroundingPairs": [
        ["(", ")"],
        ["\"", "\""],
        ["'", "'"]
    ]
}

And place cursor on each bracket to see what happens. See screeshot.

bracketbug

Also @zabel-xyz mentioned example, where brackets contains spaces, still does not work.

Hi, still don't work in this case:
"brackets": [ ["if", "end if"], ["begin", "end"] ],
1

To verify, edit one of the built-in language configuration files or create a new language if you really want to and use:

 "brackets": [
        ["if", "end if"],
        ["loop", "end loop"],
        ["begin", "end"]
    ],

Then, write some code which utilizes this, like.

  loop
    if
    end if
  end loop
end

The end should match the corresponding beginning sequence.

Please also try other variants from other comments...

@alexandrudima Thank you! I have tried in Insiders version some of examples which didn't work earlier and they all seems working now.

Don't work with begin - end:
1

2

@Danieleeee This only works if you also define if and end if as a bracket pair. If you define only begin and end, then the above screenshot shows reasonable behavior.

Yes.
You have tried and it works ?
1

@Danieleeee Yes, I have tried when I pushed fixes for this issue. There is even a unit test that passes for this case. See here

I have tried once again with the brackets you have defined:
image

And it works for me:
image

Have you tried in a VS Code build that contains the fix? i.e. an Insiders build? The 1.40 version will ship to the stable channel sometime next week.

Sorry, I don't have insiders build.
I will wait for stable version next week.
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

villiv picture villiv  路  3Comments

curtw picture curtw  路  3Comments

borekb picture borekb  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments

vsccarl picture vsccarl  路  3Comments