jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
155 stars 30 forks source link

`function.definition` changes to `function.call` if a newline is inserted after the return type #659

Open a-stewart opened 3 months ago

a-stewart commented 3 months ago

Consider the following code:

bool test1(int a) {
    return true;
}

bool
test2(int a) {
    return true;
}

Using inspect tokens and scopes, we see that test1 is defined as a entity.name.function.definition.

image

However, with the added line break, test2 is defined as a entity.name.function.call.

image

This is fine in the default VS Code theme, since these are coloured the same, however, with themes that differentiate, it results in the syntax highlighting looking off.

image

To reproduce the above, add the following to settings.json:

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": ["entity.name.function.definition.cpp"],
        "settings": {
          "fontStyle": "bold underline",
          "foreground": "#8f224c",
        }
      }
    ]
  },