Skip to content

Commit

Permalink
Fix bad continuation lines inside blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 committed Jun 15, 2024
1 parent dd31360 commit e037c69
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 15/June/2024.</p>
<p>RIDE {VERSION} was released on 16/June/2024.</p>
<!-- <br/>
<h3>May The Fourth Be With You!</h3>
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>
Expand Down
19 changes: 12 additions & 7 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,21 @@ def _sanity_check(self, data, text):
# f" result={result}")
return True if not result else result

""" DEBUG
formatted_text = data.format_text(text)
c = self._normalize(formatted_text)
e = self._normalize(text)
return len(c) == len(e)
"""
""" DEBUG
formatted_text = data.format_text(text)
c = self._normalize(formatted_text)
e = self._normalize(text)
return len(c) == len(e)
"""

""" DEBUG: This is no longer used
@staticmethod
def _normalize(text):
for item in tuple(string.whitespace) + ('...', '*'):
if item in text:
text = text.replace(item, '')
return text
"""

def _handle_sanity_check_failure(self, message):
if self._last_answer == wx.ID_NO and time() - self._last_answer_time <= 0.2:
Expand Down Expand Up @@ -517,7 +519,8 @@ def _create_target(self, content=None):
data = self.wrapper_data.data
target_class = type(data)
self._doc_language = obtain_language(self._doc_language, content=content)
# print(f"DEBUG: textedit.py DataFileWrapper _create_target self._doc_language={self._doc_language}")
# print(f"DEBUG: textedit.py DataFileWrapper _create_target self._doc_language={self._doc_language}"
# f"\n target class={target_class}")
if isinstance(data, robotapi.TestDataDirectory):
target = robotapi.TestDataDirectory(parent=None, source=self.wrapper_data.directory,
settings=self._settings, language=self._doc_language)
Expand All @@ -544,6 +547,7 @@ def _txt_data(self, data):
# print(f"DEBUG: textedit.py DataFileWrapper content _txt_data = {text=} language={self._doc_language}")
return text

""" DEBUG: This is no longer used
def collapse_blanks(self, content: str) -> str:
spaces = self._tab_size * ' '
block = []
Expand All @@ -566,6 +570,7 @@ def collapse_blanks(self, content: str) -> str:
new_text = new_text.strip(' ') + '\n'
# print(f"DEBUG: texteditor.py collapse_blanks new_text={new_text}")
return new_text
"""


class SourceEditor(wx.Panel):
Expand Down
10 changes: 7 additions & 3 deletions src/robotide/lib/robot/parsing/datarow.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ def all(self):

@property
def data(self):
""" DEBUG: Keep identation with continuation marker
if self.is_continuing():
index = self.cells.index(self._row_continuation_marker) + 1
index = self.cells.index(self._row_continuation_marker) # + 1 DEBUG: Keep the continuation marker
start = 0
if len(self.cells) > 1:
for idx in range(index, len(self.cells)):
start = idx
if self.cells[start] != '':
break
# print(f"DEBUG: datarow.py data returning from continuation row idx={start} data={self.cells}")
print(f"DEBUG: datarow.py data returning from continuation row idx={start} data={self.cells}\n"
f"returning {self.cells[start:]}")
return self.cells[start:]
return [c.strip() for c in self.cells] #self.cells
"""
return [c.strip() for c in self.cells]

def dedent(self):
# DEBUG: this is used only for debugging: import inspect
Expand Down
8 changes: 5 additions & 3 deletions src/robotide/lib/robot/parsing/tablepopulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def populate(self):
class _StepContainingTablePopulator(_TablePopulator):

def _is_continuing(self, row):
return row.is_indented() and self._populator or row.is_commented()
return row.is_indented() and self._populator or row.is_continuing() or row.is_commented()

def _is_cacheable_comment_row(self, row):
return row.is_commented() and not self._populator
Expand Down Expand Up @@ -191,6 +191,8 @@ def add(self, row):
self.row_continue = False
dedented_row = row.dedent()
if dedented_row:
if self.row_continue:
dedented_row.cells.insert(0, '') # compensation for missing indent in blocks
self._handle_data_row(dedented_row)

def _handle_data_row(self, row):
Expand All @@ -212,8 +214,8 @@ def _populating_for_loop(self):
return isinstance(self._populator, ForLoopPopulator)

def _continues(self, row):
return ((row.is_continuing() and self._populator is not None) or
(self._populating_for_loop() and row.is_indented()))
return row.is_continuing() and self._populator is not None
# or (self._populating_for_loop() and row.is_indented()))

def _populate_comment_row(self, crow):
# print("DEBUG: _populate_comment_row ENTER %s" % crow)
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/lib/robot/writer/filewriters.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def _write_table(self, table, is_last):
if not is_last: # DEBUG: make this configurable
# print(f"DEBUG: lib.robot.writer _DataFileWritter write_table empty_row table={table.type}")
try:
if table.type == 'comments' or table.type == 'variable' and len(list(table)[-1].as_list()) == 0:
if table.type == 'variable' and len(list(table)[-1].as_list()) == 0:
# DEBUG: This is workaround for newline being added ALWAYS to VariableTable
# table.type == 'comments' or
return
except IndexError:
pass
Expand Down
10 changes: 7 additions & 3 deletions src/robotide/lib/robot/writer/rowsplitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ def split(self, row, table_type):
return self._split_doc_row(row, indent)
return self._split_row(row, indent)

def _split_empty_row(self):
@staticmethod
def _split_empty_row():
yield []

def _get_indent(self, row, table_type):
indent = self._get_first_non_empty_index(row)
min_indent = 1 if table_type in self._indented_tables else 0
return max(indent, min_indent)

def _get_first_non_empty_index(self, row, indented=False):
@staticmethod
def _get_first_non_empty_index(row, indented=False):
ignore = ['', '...'] if indented else ['']
return len(list(itertools.takewhile(lambda x: x in ignore, row)))

Expand All @@ -67,7 +69,8 @@ def _split_doc_row(self, row, indent):
row = [current] if current else []
yield self._continue_row(row, indent)

def _split_doc(self, doc):
@staticmethod
def _split_doc(doc):
if '\\n' not in doc:
return doc, ''
if '\\n ' in doc:
Expand All @@ -77,6 +80,7 @@ def _split_doc(self, doc):
def _split_row(self, row, indent):
while row:
current, row = self._split(row)
# print(f"DEBUG: rowsplitter.py RowSplitter _split_row current={current} row={row}")
yield self._escape_last_cell_if_empty(current)
if row:
row = self._continue_row(row, indent)
Expand Down

0 comments on commit e037c69

Please sign in to comment.