@@ -337,19 +337,30 @@ void Initialize(MessageHandler *m, InitializeParam ¶m, ReplyOnce &reply) {
337337 // Set project root.
338338 EnsureEndsInSlash (project_path);
339339 g_config->fallbackFolder = project_path;
340+ auto &workspaceFolders = g_config->workspaceFolders ;
340341 for (const WorkspaceFolder &wf : param.workspaceFolders ) {
341342 std::string path = wf.uri .GetPath ();
342343 EnsureEndsInSlash (path);
343- g_config-> workspaceFolders . push_back (path);
344- LOG_S (INFO) << " add workspace folder " << wf. name << " : " << path ;
344+ std::string real = RealPath (path) + ' / ' ;
345+ workspaceFolders. emplace_back (path, path == real ? " " : real) ;
345346 }
346- if (param.workspaceFolders .empty ())
347- g_config->workspaceFolders .push_back (project_path);
347+ if (workspaceFolders.empty ()) {
348+ std::string real = RealPath (project_path) + ' /' ;
349+ workspaceFolders.emplace_back (project_path,
350+ project_path == real ? " " : real);
351+ }
352+ std::sort (workspaceFolders.begin (), workspaceFolders.end (),
353+ [](auto &l, auto &r) { return l.first .size () > r.first .size (); });
354+ for (auto &[folder, real] : workspaceFolders)
355+ if (real.empty ())
356+ LOG_S (INFO) << " workspace folder: " << folder;
357+ else
358+ LOG_S (INFO) << " workspace folder: " << folder << " -> " << real;
348359
349360 if (g_config->cache .directory .empty ())
350361 g_config->cache .retainInMemory = 1 ;
351362 else if (!g_config->cache .hierarchicalPath )
352- for (const std::string & folder : g_config-> workspaceFolders ) {
363+ for (auto &[ folder, _] : workspaceFolders) {
353364 // Create two cache directories for files inside and outside of the
354365 // project.
355366 std::string escaped = EscapeFileName (folder.substr (0 , folder.size () - 1 ));
@@ -358,7 +369,7 @@ void Initialize(MessageHandler *m, InitializeParam ¶m, ReplyOnce &reply) {
358369 }
359370
360371 idx::Init ();
361- for (const std::string & folder : g_config-> workspaceFolders )
372+ for (auto &[ folder, _] : workspaceFolders)
362373 m->project ->Load (folder);
363374
364375 // Start indexer threads. Start this after loading the project, as that
0 commit comments