diff --git a/CHANGELOG.md b/CHANGELOG.md index dda91be8..fd16eae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Fixed bug with Fixed Format references being incorrectly detected in comments ([#447](https://github.com/fortran-lang/fortls/issues/447)) +- Fixed bug with where form feed characters broke LSP features + ([#443](https://github.com/fortran-lang/fortls/issues/443)) ## 3.1.2 diff --git a/fortls/parsers/internal/parser.py b/fortls/parsers/internal/parser.py index d63cfe4d..174d1499 100644 --- a/fortls/parsers/internal/parser.py +++ b/fortls/parsers/internal/parser.py @@ -840,6 +840,11 @@ def find_external( return False +def splitlines(text: str) -> list[str]: + """Split text into lines by \r\n, \n, or \r""" + return re.split(r"\n|\r\n?", text) + + class FortranFile: def __init__(self, path: str = None, pp_suffixes: list = None): self.path: str = path @@ -900,7 +905,7 @@ def load_from_disk(self) -> tuple[str | None, bool | None]: return None, False self.hash = hash - self.contents_split = contents.splitlines() + self.contents_split = splitlines(contents) self.fixed = detect_fixed_format(self.contents_split) self.contents_pp = self.contents_split self.nLines = len(self.contents_split) @@ -956,7 +961,7 @@ def check_change_reparse(line_no: int) -> bool: if len(text) == 0: text_split = [""] else: - text_split = text.splitlines() + text_split = splitlines(text) # Check for ending newline if (text[-1] == "\n") or (text[-1] == "\r"): text_split.append("")