Skip to content

Commit 0956a47

Browse files
committed
Fixed LSP error messages for config files are not issues correctly #135
1 parent cbc6892 commit 0956a47

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
- Added `sitemap.xml` to documentation webpage
1010
([#134](https://github.com/gnikit/fortls/pull/134))
1111

12+
### Fixed
13+
14+
- Fixed bug where error messages did not post correctly
15+
([#135](https://github.com/gnikit/fortls/issues/135))
16+
1217
## 2.7.0
1318

1419
### Added

fortls/langserver.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,11 @@ def _load_config_file(self) -> None:
14921492

14931493
# Check for config file
14941494
config_path = os.path.join(self.root_path, self.config)
1495+
# NOTE: it would be better if we could distinguish between a user-defined
1496+
# and a default config file. If not user-defined then we can check for
1497+
# default names, currently only .fortls. If None are found return None
1498+
# if user-defined config we would want to throw an error if the file
1499+
# cannot be found
14951500
if not os.path.isfile(config_path):
14961501
return None
14971502

@@ -1521,14 +1526,12 @@ def _load_config_file(self) -> None:
15211526
self.debug_log = True
15221527

15231528
except FileNotFoundError:
1524-
self.post_messages(
1525-
[Severity.error, f"Error settings file '{self.config}' not found"]
1526-
)
1529+
self.post_message(f"Configuration file '{self.config}' not found")
15271530

1528-
except ValueError:
1529-
self.post_messages(
1530-
[Severity.error, f"Error while parsing '{self.config}' settings file"]
1531-
)
1531+
# Erroneous json file syntax
1532+
except ValueError as e:
1533+
msg = f"Error: '{e}' while reading '{self.config}' Configuration file"
1534+
self.post_message(msg)
15321535

15331536
def _load_config_file_dirs(self, config_dict: dict) -> None:
15341537
# Exclude paths (directories & files)
@@ -1545,7 +1548,7 @@ def _load_config_file_dirs(self, config_dict: dict) -> None:
15451548
self.source_dirs.update(set(dirs))
15461549
except FileNotFoundError as e:
15471550
err = f"Directories input in Configuration file do not exit:\n{e}"
1548-
self.post_messages([Severity.warn, err])
1551+
self.post_message(err, Severity.warn)
15491552

15501553
# Keep all directories present in source_dirs but not excl_paths
15511554
self.source_dirs = {i for i in self.source_dirs if i not in self.excl_paths}
@@ -1617,7 +1620,7 @@ def _load_config_file_preproc(self, config_dict: dict) -> None:
16171620
self.include_dirs.update(set(dirs))
16181621
except FileNotFoundError as e:
16191622
err = f"Directories input in Configuration file do not exit:\n{e}"
1620-
self.post_messages([Severity.warn, err])
1623+
self.post_message(err, Severity.warn)
16211624

16221625
def _add_source_dirs(self) -> None:
16231626
"""Will recursively add all subdirectories that contain Fortran

0 commit comments

Comments
 (0)