Skip to content

Commit 43b3070

Browse files
committed
use regex to splitlines in robotidy formatting
1 parent 0372220 commit 43b3070

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

robotcode/language_server/robotframework/parts/formatting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import io
55
import os
6+
import re
67
from typing import TYPE_CHECKING, Any, List, Optional, cast
78

89
from ....utils.async_tools import threaded
@@ -78,6 +79,8 @@ async def format(
7879

7980
return None
8081

82+
RE_LINEBREAKS = re.compile(r"\r\n|\r|\n")
83+
8184
async def format_robot_tidy(
8285
self, document: TextDocument, options: FormattingOptions, **further_options: Any
8386
) -> Optional[List[TextEdit]]:
@@ -96,7 +99,7 @@ async def format_robot_tidy(
9699
if not changed:
97100
return None
98101

99-
new_lines = new.text.splitlines()
102+
new_lines = self.RE_LINEBREAKS.split(new.text)
100103

101104
result: List[TextEdit] = []
102105
matcher = SequenceMatcher(a=await document.get_lines(), b=new_lines, autojunk=False)

0 commit comments

Comments
 (0)