-
Notifications
You must be signed in to change notification settings - Fork 37
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: Update contents before diagnosticRequestFile #1100
lsp: Update contents before diagnosticRequestFile #1100
Conversation
@@ -115,9 +115,8 @@ type LanguageServer struct { | |||
|
|||
// fileUpdateEvent is sent to a channel when an update is required for a file. | |||
type fileUpdateEvent struct { | |||
Reason string | |||
URI string | |||
Content string |
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.
This has been removed so it's no longer possible to send fileUpdateEvents with no content, this reduces the responsibility on the diagnostics worker. Now it can just update parses and send diagnostics.
@@ -212,9 +211,11 @@ func (l *LanguageServer) StartDiagnosticsWorker(ctx context.Context) { | |||
case <-ctx.Done(): | |||
return | |||
case evt := <-l.diagnosticRequestFile: | |||
err := l.processTextContentUpdate(ctx, evt.URI, evt.Content) | |||
// updateParse will not return an error when the parsing failed, |
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.
processTextContentUpdate has been removed and inlined here.
@@ -260,9 +265,42 @@ func (l *LanguageServer) StartHoverWorker(ctx context.Context) { | |||
case <-ctx.Done(): | |||
return | |||
case evt := <-l.builtinsPositionFile: | |||
err := l.processHoverContentUpdate(ctx, evt.URI, evt.Content) | |||
fileURI := evt.URI |
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.
processHoverContentUpdate has also been inlined here.
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.
I'd lie if I said I understood this fully, but I think I followed along pretty well :)
Reason: "internal/templateNewFile", | ||
URI: fileURI, | ||
Content: newContents, | ||
Reason: "internal/templateNewFile", |
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.
The actual issue this fixes was triggered by
Where an empty update was sent causing the cache's state to be set to blank for files when they were detected as new, despite them first having their contents loaded from disk.
a65ce07
to
1a3d2f0
Compare
One of the main causes for the 'empty module' error stemmed from the sending of diagnosticRequestFile events with no content. One solution would have been to fetch the content when processing events on the diagnosticRequestFile channel, however it felt like the publisher had more knowledge of how to do this correctly and processing diagnosticRequestFile was getting unwieldy. I have removed the content from diagnosticRequestFile, and these events will just update the parse and send diagnostics. This should be less surprising. Signed-off-by: Charlie Egan <charlie@styra.com>
1a3d2f0
to
424b17a
Compare
One of the main causes for the 'empty module' error stemmed from the sending of diagnosticRequestFile events with no content. One solution would have been to fetch the content when processing events on the diagnosticRequestFile channel, however it felt like the publisher had more knowledge of how to do this correctly and processing diagnosticRequestFile was getting unwieldy. I have removed the content from diagnosticRequestFile, and these events will just update the parse and send diagnostics. This should be less surprising. Signed-off-by: Charlie Egan <charlie@styra.com>
One of the main causes for the 'empty module' error stemmed from the sending of diagnosticRequestFile events with no content.
One solution would have been to fetch the content when processing events on the diagnosticRequestFile channel, however it felt like the publisher had more knowledge of how to do this correctly and processing diagnosticRequestFile was getting unwieldy.
I have removed the content from diagnosticRequestFile, and these events will just update the parse and send diagnostics. This should be less surprising.