From 3d26e6038e1f2ab4620a19b3fa3152fd49fd8838 Mon Sep 17 00:00:00 2001 From: w3lld1 <42353747+w3lld1@users.noreply.github.com> Date: Fri, 17 Jul 2026 08:28:46 +0200 Subject: [PATCH] fix: recognize variable-width space separators --- src/robotide/lib/robot/parsing/robotreader.py | 26 +++++-------------- utest/lib/robot/parsing/test_robotreader.py | 17 ++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 utest/lib/robot/parsing/test_robotreader.py diff --git a/src/robotide/lib/robot/parsing/robotreader.py b/src/robotide/lib/robot/parsing/robotreader.py index 475ca3d11..e2caf5197 100644 --- a/src/robotide/lib/robot/parsing/robotreader.py +++ b/src/robotide/lib/robot/parsing/robotreader.py @@ -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}") diff --git a/utest/lib/robot/parsing/test_robotreader.py b/utest/lib/robot/parsing/test_robotreader.py new file mode 100644 index 000000000..5e54b4714 --- /dev/null +++ b/utest/lib/robot/parsing/test_robotreader.py @@ -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", + ]