Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/robotide/lib/robot/parsing/robotreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,11 @@ def check_separator(self, line):
return
if not self._cell_section:
return
spc = idx = nospc = 0
for idx in range(0, len(line)):
if line[idx] != ' ':
nospc += 1
# if spc <= 2:
# spc = -1
#
if spc >= 2:
break
spc = 0
elif line[idx] == ' ': # and nospc > 0:
spc += 1
if nospc > 0 and spc < 2: # We need a step, not test case or kw name (nospc == 0 and spc <= 2 or )
content = line.lstrip(' \t\xa0')
separator = re.search(r"[ \xa0]{2,}|\t+", content)
if not separator:
return
spc = max(2, spc)
if 2 <= spc <= 10: # This max limit is reasonable
self._spaces = spc
self._space_splitter = re.compile(r"[ \t\xa0]{" + f"{self._spaces}" + "}|\t+")
self._separator_check = True
# print(f"DEBUG: RFLib RobotReader check_separator changed spaces={self._spaces}")
self._spaces = max(2, len(separator.group()))
self._space_splitter = re.compile(r"[ \xa0]{2,}|\t+")
self._separator_check = True
# print(f"DEBUG: RFLib RobotReader check_separator changed spaces={self._spaces}")
17 changes: 17 additions & 0 deletions utest/lib/robot/parsing/test_robotreader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from robotide.lib.robot.parsing.robotreader import RobotReader


def test_reads_two_space_separators_when_four_spaces_are_configured():
reader = RobotReader(spaces=4, lang=["en"])
reader.check_separator("*** Test Cases ***")
reader.check_separator("First test case")
row = " Keyword with two arguments arg1 arg2"

reader.check_separator(row)

assert reader.split_row(row) == [
"",
"Keyword with two arguments",
"arg1",
"arg2",
]
Loading