Skip to content

Commit 412b6bc

Browse files
committed
[vscode_projects:1.4] Normalize paths
Resolve symlinks to make sure only unique results are returned
1 parent 6892f1c commit 412b6bc

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

vscode_projects/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from albert import *
1010

1111
md_iid = "2.3"
12-
md_version = "1.3"
12+
md_version = "1.4"
1313
md_name = "VSCode projects"
1414
md_description = "Open VSCode projects"
1515
md_url = "https://github.com/albertlauncher/python/tree/master/vscode_projects"
@@ -372,17 +372,19 @@ def _searchInRecentFiles(self, matcher: Matcher, results: dict[str, SearchResult
372372
for path in self._configStoragePaths:
373373
c = self._getStorageConfig(path)
374374
for proj in c.projects:
375-
if matcher.match(proj.name) or matcher.match(proj.path):
376-
results[proj.path] = self._getHigherPriorityResult(
375+
# Resolve sym links to get unique results
376+
resolvedPath = str(Path(proj.path).resolve())
377+
if matcher.match(proj.name) or matcher.match(proj.path) or matcher.match(resolvedPath):
378+
results[resolvedPath] = self._getHigherPriorityResult(
377379
SearchResult(
378380
project=proj,
379381
priority=self.priorityRecent,
380382
sortIndex=sortIndex
381383
),
382-
results.get(proj.path),
384+
results.get(resolvedPath),
383385
)
384386

385-
if results.get(proj.path) is not None:
387+
if results.get(resolvedPath) is not None:
386388
sortIndex += 1
387389

388390
return results
@@ -391,35 +393,37 @@ def _searchInProjectManager(self, matcher: Matcher, results: dict[str, SearchRes
391393
for path in self._configProjectManagerPaths:
392394
c = self._getProjectManagerConfig(path)
393395
for proj in c.projects:
396+
# Resolve sym links to get unique results
397+
resolvedPath = str(Path(proj.path).resolve())
394398
if matcher.match(proj.name):
395-
results[proj.path] = self._getHigherPriorityResult(
399+
results[resolvedPath] = self._getHigherPriorityResult(
396400
SearchResult(
397401
project=proj,
398402
priority=self.priorityPMName,
399403
sortIndex=0 if matcher.match(proj.name).isExactMatch() else 1
400404
),
401-
results.get(proj.path),
405+
results.get(resolvedPath),
402406
)
403407

404-
if matcher.match(proj.path):
405-
results[proj.path] = self._getHigherPriorityResult(
408+
if matcher.match(proj.path) or matcher.match(resolvedPath):
409+
results[resolvedPath] = self._getHigherPriorityResult(
406410
SearchResult(
407411
project=proj,
408412
priority=self.priorityPMPath,
409413
sortIndex=1
410414
),
411-
results.get(proj.path),
415+
results.get(resolvedPath),
412416
)
413417

414418
for tag in proj.tags:
415419
if matcher.match(tag):
416-
results[proj.path] = self._getHigherPriorityResult(
420+
results[resolvedPath] = self._getHigherPriorityResult(
417421
SearchResult(
418422
project=proj,
419423
priority=self.priorityPMTag,
420424
sortIndex=1
421425
),
422-
results.get(proj.path),
426+
results.get(resolvedPath),
423427
)
424428
break
425429

0 commit comments

Comments
 (0)