Skip to content

Commit ed52bc1

Browse files
tomotognikit
authored andcommitted
fix: not treat form feed as line break (fortran-lang#443)
1 parent e94e8ce commit ed52bc1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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)