-
Notifications
You must be signed in to change notification settings - Fork 35
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: Correct Path to URI encoding #1083
Conversation
Spaces must be encoded as %20. This case causing the state worker to reload contents from disk as it appeared a file did not exist in the cache. Signed-off-by: Charlie Egan <[email protected]>
@@ -211,18 +211,14 @@ func (l *LanguageServer) StartDiagnosticsWorker(ctx context.Context) { | |||
case <-ctx.Done(): | |||
return | |||
case evt := <-l.diagnosticRequestFile: | |||
success, err := l.processTextContentUpdate(ctx, evt.URI, evt.Content) | |||
err := l.processTextContentUpdate(ctx, evt.URI, evt.Content) |
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 updated to avoid any special handling of parse errors. diagnostics are always sent from the parent now. This is unrelated to the title fix.
@@ -936,33 +932,24 @@ func (l *LanguageServer) processTextContentUpdate( | |||
ctx context.Context, |
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.
See note above, this function now just attempts to update the parse if the content changed.
@@ -2132,7 +2119,7 @@ func (l *LanguageServer) loadWorkspaceContents(ctx context.Context, newOnly bool | |||
} | |||
|
|||
// if the caller has requested only new files, then we can exit early | |||
if _, ok := l.cache.GetModule(fileURI); newOnly && ok { | |||
if _, ok := l.cache.GetFileContents(fileURI); newOnly && ok { |
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 best proxy for 'Existence in the cache' is file contents and not a parsed module. This is related to the fix, but is in addition to the required change.
@@ -19,6 +19,9 @@ func FromPath(client clients.Identifier, path string) string { | |||
// Convert Windows path separators to Unix separators | |||
path = filepath.ToSlash(path) | |||
|
|||
// spaces must be percent-encoded | |||
path = strings.ReplaceAll(path, " ", "%20") |
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 is the fix, going from paths to URIs when paths contained spaces was broken. This meant files were being reloaded from disk at incorrect times.
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.
Good find!
@@ -19,6 +19,9 @@ func FromPath(client clients.Identifier, path string) string { | |||
// Convert Windows path separators to Unix separators | |||
path = filepath.ToSlash(path) | |||
|
|||
// spaces must be percent-encoded | |||
path = strings.ReplaceAll(path, " ", "%20") |
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.
Good find!
Spaces must be encoded as %20. This case causing the state worker to reload contents from disk as it appeared a file did not exist in the cache. Signed-off-by: Charlie Egan <[email protected]>
Spaces must be encoded as %20. This case causing the state worker to reload contents from disk as it appeared a file did not exist in the cache.