Skip to content

Commit 08c20b9

Browse files
authored
Merge pull request #224 from gnikit/gnikit/issue221
fix(debug): erroneous loading of config files
2 parents 05850c5 + bc3cb16 commit 08c20b9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
### Fixed
2222

23+
- Fixed debug interface parser not loading all configuration files
24+
([#221](https://github.com/gnikit/fortls/issues/221))
2325
- Fixed name mangling of type-bound procedure pointers while hovering
2426
([#214](https://github.com/gnikit/fortls/issues/214))
2527
- Fixed parsing start of multilines into AST

fortls/__init__.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,22 @@ def debug_server_parser(args):
451451
args : Namespace
452452
The arguments parsed from the `ArgumentParser`
453453
"""
454+
455+
def locate_config(root: str) -> str | None:
456+
default_conf_files = [args.config, ".fortlsrc", ".fortls.json", ".fortls"]
457+
present_conf_files = [
458+
os.path.isfile(os.path.join(root, f)) for f in default_conf_files
459+
]
460+
if not any(present_conf_files):
461+
return None
462+
463+
# Load the first config file found
464+
for f, present in zip(default_conf_files, present_conf_files):
465+
if not present:
466+
continue
467+
config_path = os.path.join(root, f)
468+
return config_path
469+
454470
if args.debug_filepath is None:
455471
error_exit("'debug_filepath' not specified for parsing test")
456472
file_exists = os.path.isfile(args.debug_filepath)
@@ -461,7 +477,8 @@ def debug_server_parser(args):
461477
pp_defs = {}
462478
include_dirs = set()
463479
if args.debug_rootpath:
464-
config_path = os.path.join(args.debug_rootpath, args.config)
480+
# Check for config files
481+
config_path = locate_config(args.debug_rootpath)
465482
config_exists = os.path.isfile(config_path)
466483
if config_exists:
467484
try:
@@ -479,7 +496,7 @@ def debug_server_parser(args):
479496
pp_defs = {key: "" for key in pp_defs}
480497
except:
481498
print(f"Error while parsing '{args.config}' settings file")
482-
#
499+
483500
print("\nTesting parser")
484501
print(' File = "{}"'.format(args.debug_filepath))
485502
file_obj = FortranFile(args.debug_filepath, pp_suffixes)

0 commit comments

Comments
 (0)