File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2222- Fixed crash when hovering over local in incomplete syntax tree
2323- Fixed language server not working for newly created files not yet stored on disk
2424- Luau LSP will now activate if you run an LSP command
25+ - Fixed finding the incorrect workspace folder to analyze with in a multi-workspace environment
2526
2627## [ 1.7.1] - 2022-07-17
2728
Original file line number Diff line number Diff line change @@ -21,13 +21,32 @@ using ClientPtr = std::shared_ptr<Client>;
2121// / If no workspace is found, the file is attached to the null workspace
2222WorkspaceFolderPtr LanguageServer::findWorkspace(const lsp::DocumentUri file)
2323{
24+ WorkspaceFolderPtr bestWorkspace = nullptr ;
25+ size_t length = 0 ;
26+ auto checkStr = file.toString ();
27+
28+
2429 for (auto & workspace : workspaceFolders)
2530 {
26- if (workspace->isInWorkspace (file))
31+ if (file == workspace->rootUri )
32+ return workspace;
33+
34+ // Check if the root uri is a prefix of the file
35+ auto prefixStr = workspace->rootUri .toString ();
36+ auto size = prefixStr.size ();
37+ if (size < length)
38+ continue ;
39+
40+ if (checkStr.compare (0 , size, prefixStr) == 0 )
2741 {
28- return workspace; // TODO: should we return early here? maybe a better match comes along?
42+ bestWorkspace = workspace;
43+ length = size;
2944 }
3045 }
46+
47+ if (bestWorkspace)
48+ return bestWorkspace;
49+
3150 client->sendTrace (" cannot find workspace for " + file.toString ());
3251 return nullWorkspace;
3352}
You can’t perform that action at this time.
0 commit comments