Skip to content

Commit e0fb5e3

Browse files
committed
Add support for absolute include paths
1 parent 151eb42 commit e0fb5e3

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 2.0.1
44

5+
### Added
6+
7+
- Add support for absolute include, source and exclude paths
8+
59
### Changed
610

711
- Changed `USE_info` named tuple to storing use modules as `sets` instead of `lists`

fortls/helper_functions.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def get_line_prefix(pre_lines: list, curr_line: str, col: int, qs: bool = True)
258258

259259

260260
def resolve_globs(glob_path: str, root_path: str = None) -> list[str]:
261-
"""Resolve glob patterns
261+
"""Resolve paths (absolute and relative) and glob patterns
262262
263263
Parameters
264264
----------
@@ -277,16 +277,14 @@ def resolve_globs(glob_path: str, root_path: str = None) -> list[str]:
277277
Expanded glob patterns with absolute paths.
278278
Absolute paths are used to resolve any potential ambiguity
279279
"""
280-
# Path.glob returns a generator, we then cast the Path obj to a str
281-
# alternatively use p.as_posix()
282-
if root_path:
283-
return [str(p) for p in Path(root_path).resolve().glob(glob_path)]
284-
# Attempt to extract the root and glob pattern from the glob_path
285-
# This is substantially less robust that then above
280+
# Resolve absolute paths i.e. not in our root_path
281+
if os.path.isabs(glob_path) or not root_path:
282+
p = Path(glob_path).resolve()
283+
root = p.root
284+
rel = str(p.relative_to(root)) # contains glob pattern
285+
return [str(p.resolve()) for p in Path(root).glob(rel)]
286286
else:
287-
p = Path(glob_path).expanduser()
288-
parts = p.parts[p.is_absolute() :]
289-
return [str(i) for i in Path(p.root).resolve().glob(str(Path(*parts)))]
287+
return [str(p.resolve()) for p in Path(root_path).resolve().glob(glob_path)]
290288

291289

292290
def only_dirs(paths: list[str], err_msg: list = []) -> list[str]:

0 commit comments

Comments
 (0)