microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.7k stars 29.45k forks source link

`setLanguageConfiguration` throws "$.exec is not a function" in different cirumstances #171194

Closed brettfo closed 1 year ago

brettfo commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Create an extension with a custom language.
  2. Add a command that calls the function vscode.languages.setLanguageConfiguration(...) where the language configuration object contains just the wordPattern property.

E.g., the language configuration object could look like this:

{
  "wordPattern": "abc"
}

Result:

An exception is thrown with the text "$.exec is not a function" and the language configuration is not applied.

N.b., when this bug was initially encountered, the only language configurations that resulted in this error contained a literal $ character (e.g., "wordPattern": "\\$"), but when digging deeper, I found that this scenario also broken. It's likely the same underlying issue.

brettfo commented 1 year ago

If it helps with debugging, I'm a MSFT employee on the .NET Interactive team (github.com/dotnet/interactive) and I'm free to do a screen share. My internal alias is brettfo.

jrieken commented 1 year ago

"wordPattern": "abc"

That looks like an invalid data. The spec'd type for wordPattern is RegExp, not string. See https://insiders.vscode.dev/github/microsoft/vscode/blob/d06d615e33c04a956bf6b7da38908b783197b63e/src/vscode-dts/vscode.d.ts#L5748

jrieken commented 1 year ago

closing this as question/invalid

brettfo commented 1 year ago

Is there a constructor or factory method to deserialize a language configuration? Ultimately I'm reading language-configuration.json files from disk any dyanmically applying them with setLanguageConfiguration. Looking through this repo, there appear to be different ways to specify the word pattern:

Moreover, the documentation states that a string can be directly used, but presumably this is going through an internal parse function?

jrieken commented 1 year ago

Yes, the language configuration files aren't being read via the API but directly in the renderer. There is no automatic deserialise