Skip to content

Commit 9a86506

Browse files
authored
Merge pull request #444 from tomoto/fix/form-feed-issue
fix: not treat form feed as line break (#443)
2 parents bb3f6dc + 50d72b3 commit 9a86506

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

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

77
- Fixed bug with Fixed Format references being incorrectly detected in comments
88
([#447](https://github.com/fortran-lang/fortls/issues/447))
9+
- Fixed bug with where form feed characters broke LSP features
10+
([#443](https://github.com/fortran-lang/fortls/issues/443))
911

1012
## 3.1.2
1113

fortls/parsers/internal/parser.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ def find_external(
840840
return False
841841

842842

843+
def splitlines(text: str) -> list[str]:
844+
"""Split text into lines by \r\n, \n, or \r"""
845+
return re.split(r"\n|\r\n?", text)
846+
847+
843848
class FortranFile:
844849
def __init__(self, path: str = None, pp_suffixes: list = None):
845850
self.path: str = path
@@ -900,7 +905,7 @@ def load_from_disk(self) -> tuple[str | None, bool | None]:
900905
return None, False
901906

902907
self.hash = hash
903-
self.contents_split = contents.splitlines()
908+
self.contents_split = splitlines(contents)
904909
self.fixed = detect_fixed_format(self.contents_split)
905910
self.contents_pp = self.contents_split
906911
self.nLines = len(self.contents_split)
@@ -956,7 +961,7 @@ def check_change_reparse(line_no: int) -> bool:
956961
if len(text) == 0:
957962
text_split = [""]
958963
else:
959-
text_split = text.splitlines()
964+
text_split = splitlines(text)
960965
# Check for ending newline
961966
if (text[-1] == "\n") or (text[-1] == "\r"):
962967
text_split.append("")

0 commit comments

Comments
 (0)