-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: register providers only for languages matching the documentSelector #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -492,4 +526,16 @@ export class MonacoLanguages implements Languages { | |||
return selector === model.languageId; | |||
} | |||
|
|||
protected matchLanguage(selector: string | DocumentFilter | DocumentSelector, languageId: string): boolean { | |||
if (Array.isArray(selector)) { | |||
return selector.findIndex(filter => this.matchLanguage(filter, languageId)) !== -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi: selector.some(...)
=== selector.findIndex(...) !== -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I would have used "some", but I saw findIndex used in matchModel and thought it's a coding standard you want to stick to. Will keep in mind for future PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, I will change it in: #100
I won't use monaco-json together with json LS. It would be confusing for a user. I like the changes nevertheless. |
@gins3000 thanks for your contribution, please ⭐️ the repo 🙏 if you like it :) |
@akosyakov thanks for the thorough and fast review. I checked, and saw that, indeed, I hadn't starred the repo yet and rectified that ;) |
Previously, providers were registered for every registered language, not just for the ones matching the documentSelector array passed to the LanguageClient config.
With this fix, language-specific providers are only registered for an existing language if there is a chance of matching, i.e.:
This reduces the risk of a conflict with existing providers, e.g. when using monaco-languages or monaco-json.