Repository navigation
Make LSP server load content mappers only from node_modules inside workspace folders #64837
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
base: main
Are you sure you want to change the base?
Changes from all commits
0d482b5
4cd6440
4aadc36
1b4346a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1745,6 +1745,8 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali | |
| s.logger.Logf("file watching: disabled (client lacks dynamic watch registration and builtin watcher backend is not fast-recursive)") | ||
| } | ||
|
|
||
| workspaceRoots := getInitialWorkspaceRoots(s.initializeParams) | ||
|
|
||
| cwd := s.cwd | ||
| if s.clientCapabilities.Workspace.WorkspaceFolders && | ||
| s.initializeParams.WorkspaceFolders != nil && | ||
|
|
@@ -1778,6 +1780,7 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali | |
| DebounceDelay: 500 * time.Millisecond, | ||
| PushDiagnosticsEnabled: !disablePushDiagnostics, | ||
| RunExternalCode: runExternalCode, | ||
| InitialWorkspaceRoots: workspaceRoots, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intentionally deferred because we just literally don't do anything correctly with workspace folders. I wasn't intending to add full support here, and "remove a folder from a workspace that was previously open in a trusted window" doesn't mean you stopped trusting it. |
||
| }, | ||
| FS: s.fs, | ||
| Logger: s.logger, | ||
|
|
@@ -1838,6 +1841,23 @@ func (s *Server) handleExit(ctx context.Context, _ lsproto.NoParams) error { | |
| return io.EOF | ||
| } | ||
|
|
||
| func getInitialWorkspaceRoots(params *lsproto.InitializeParams) []tspath.RootedDirectoryPath { | ||
| workspaceRoots := []tspath.RootedDirectoryPath{} | ||
| if params.WorkspaceFolders != nil && params.WorkspaceFolders.WorkspaceFolders != nil { | ||
| for _, folder := range *params.WorkspaceFolders.WorkspaceFolders { | ||
| uri := lsproto.DocumentUri(folder.Uri) | ||
| if strings.HasPrefix(string(uri), "file://") { | ||
| workspaceRoots = append(workspaceRoots, tspath.RootedDirectoryPathFromPath(uri.Path())) | ||
| } | ||
| } | ||
| } else if params.RootUri.DocumentUri != nil && strings.HasPrefix(string(*params.RootUri.DocumentUri), "file://") { | ||
| workspaceRoots = append(workspaceRoots, tspath.RootedDirectoryPathFromPath(params.RootUri.DocumentUri.Path())) | ||
| } else if params.RootPath != nil && params.RootPath.String != nil && tspath.PathIsAbsolute(*params.RootPath.String) { | ||
| workspaceRoots = append(workspaceRoots, tspath.RootedDirectoryPathFromAbsolute(*params.RootPath.String)) | ||
| } | ||
| return workspaceRoots | ||
| } | ||
|
|
||
| func (s *Server) handleDidChangeWorkspaceConfiguration(ctx context.Context, params *lsproto.DidChangeConfigurationParams) error { | ||
| if params.Settings == nil { | ||
| return nil | ||
|
|
||
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.
When does fourslash ever do this?
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.
All the content mapper fourslash tests do, in fact. I suppose it's not necessary, just kind of inherited from
// @runExternalCode: truein compiler tests, which is useful for testing what the diagnostic looks like when it's not there.