-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[LSP] Respect settings passed in by LSP in AutoInsertHandler #51916
Conversation
if (document == null) | ||
{ | ||
return null; | ||
} | ||
|
||
var service = document.GetRequiredLanguageService<IDocumentationCommentSnippetService>(); | ||
|
||
// We should use the options passed in by LSP instead of the document's options. | ||
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); |
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.
are the options passed in by LSP correct? Like for example if you have an editor config setting for tabs vs spaces. Does LSP read that? Similarly for tools options settings.
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.
From testing with Razor, it correctly recognizes changes in Tools->Option settings. I'm not sure about editorconfig, will test shortly.
Regardless, I think we need this change since Razor files won't be correctly formatted without it, namely because we need to use Razor's Tools->Options settings instead of C#'s.
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.
It does indeed seem to support editorconfig as well (at least in C#, I think I recall editorconfig currently being unsupported for Razor files).
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.
Ok, I think it's probably fine to make this change, just one more question
Regardless, I think we need this change since Razor files won't be correctly formatted without it, namely because we need to use Razor's Tools->Options settings instead of C#'s.
Ah, and I guess with the dynamic file info they provide they don't have a way to set those options on the generated document?
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.
Ah, and I guess with the dynamic file info they provide they don't have a way to set those options on the generated document?
Even if that were the case I wouldn't imagine we'd want to. Given the platform is the owner of settings it should be the one informing you on what settings to use. Out of curiosity does on type formatting or document formatting have this same gap?
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.
Out of curiosity does on type formatting or document formatting have this same gap?
From a glance, this does seem to be the case. I can address this in a follow up PR.
Today, LSP passes in tabs/spaces settings as part of the OnAutoInsert request. However, we do not respect these settings and instead use the document's options. We should respect the LSP settings.
This will partially fix some of the tabs vs. spaces issues seen in Razor.