Skip to content

Commit 9056859

Browse files
Commented cells (#2618)
* Fix not possible to delete # commented cells in Grid Editor * Sharp comment and uncomment rows. WIP, needs decision when single cell, needs undo state save * Final code. Initial unit tests * Fix syncronizing expand/collapse of settings panel on Linux. Closes #2598
1 parent 3ca133e commit 9056859

File tree

13 files changed

+175
-21
lines changed

13 files changed

+175
-21
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
1616

1717
== Fixed
1818

19+
- Fixed non syncronized expanding/collapse of Settings panel in Grid Editor, on Linux
20+
- Fixed not working the deletion of cells commented with ``\# `` in Grid Editor with ``Ctrl-Shift-D``
1921
- Fixed empty line being always added to the Variables section in Text Editor
2022
- Fixed wrong project reloading when file system changes detected, and other related problems
2123
- Fixed control commands (``FOR``, ``IF``, ``TRY``, etc) being colorized as valid keywords when typed not in all caps in Grid Editor

src/robotide/application/CHANGELOG.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
Added sincronization with Project Explorer to navigate to selected item, Test Case, Keyword, Variable, in Text Editor
77
Note: This feature is working fine in Fedora 38, but not on Windows and macOS.
88
</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_fixed"></a>2. Fixed</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
9+
Fixed non syncronized expanding/collapse of Settings panel in Grid Editor, on Linux
10+
</li><li class="listitem">
11+
Fixed not working the deletion of cells commented with ``\# `` in Grid Editor with ``Ctrl-Shift-D``
12+
</li><li class="listitem">
913
Fixed empty line being always added to the Variables section in Text Editor
1014
</li><li class="listitem">
1115
Fixed wrong project reloading when file system changes detected, and other related problems

src/robotide/application/releasenotes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def set_content(self, html_win, content):
147147
<p><a class="reference external" href="https://github.com/robotframework/RIDE/">RIDE (Robot Framework IDE)</a>
148148
{VERSION} is a new release with minor enhancements and bug fixes. The reference for valid arguments is
149149
<a class="reference external" href="https://robotframework.org/">Robot Framework</a> installed version, which is at this
150-
moment 6.0.2. However, internal library is based on version 3.1.2, to keep compatibility with old formats.</p>
150+
moment 6.1.1. However, internal library is based on version 3.1.2, to keep compatibility with old formats.</p>
151151
<p></p>
152152
<ul class="simple">
153153
<li>This version supports Python 3.6 up to 3.11.</li>
@@ -168,6 +168,8 @@ def set_content(self, html_win, content):
168168
</ul>
169169
<p><strong>New Features and Fixes Highlights</strong></p>
170170
<ul class="simple">
171+
<li>Fixed non syncronized expanding/collapse of Settings panel in Grid Editor, on Linux</li>
172+
<li>Fixed not working the deletion of cells commented with ``# `` in Grid Editor with ``Ctrl-Shift-D``</li>
171173
<li>Fixed empty line being always added to the Variables section in Text Editor</li>
172174
<li>Improved project file system changes and reloading</li>
173175
<li>Added context menu to RIDE tray icon. Options Show, Hide and Close</li>
@@ -227,6 +229,6 @@ def set_content(self, html_win, content):
227229
<pre class="literal-block">
228230
python -m robotide.postinstall -install
229231
</pre>
230-
<p>RIDE {VERSION} was released on 30/Jul/2023.</p>
232+
<p>RIDE {VERSION} was released on 06/Aug/2023.</p>
231233
</div>
232234
"""

src/robotide/controller/ctrlcommands.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,26 @@ def _get_undo_command(self):
12161216
return CommentRow(self._row)
12171217

12181218

1219+
class SharpCommentRow(_RowChangingCommand):
1220+
1221+
def _change_value(self, context):
1222+
self._step(context).sharp_comment()
1223+
return True
1224+
1225+
def _get_undo_command(self):
1226+
return SharpUncommentRow(self._row)
1227+
1228+
1229+
class SharpUncommentRow(_RowChangingCommand):
1230+
1231+
def _change_value(self, context):
1232+
self._step(context).sharp_uncomment()
1233+
return True
1234+
1235+
def _get_undo_command(self):
1236+
return SharpCommentRow(self._row)
1237+
1238+
12191239
INDENTED_INNER = ['ELSE', 'ELSE IF', 'EXCEPT', 'FINALLY']
12201240
INDENTED_START = ['FOR', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER
12211241

@@ -1502,6 +1522,14 @@ def uncomment_rows(rows):
15021522
return StepsChangingCompositeCommand(*[UncommentRow(r) for r in rows])
15031523

15041524

1525+
def sharp_comment_rows(rows):
1526+
return StepsChangingCompositeCommand(*[SharpCommentRow(r) for r in rows])
1527+
1528+
1529+
def sharp_uncomment_rows(rows):
1530+
return StepsChangingCompositeCommand(*[SharpUncommentRow(r) for r in rows])
1531+
1532+
15051533
def clear_area(top_left, bottom_right):
15061534
row_s, col_s = top_left
15071535
row_e, col_e = bottom_right

src/robotide/controller/stepcontrollers.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@ def comment(self):
325325
col = self._first_non_empty_cell() # .step_controller_step.inner_kw_pos
326326
self.insert_value_before(col, 'Comment')
327327

328+
def sharp_comment(self):
329+
col = self._first_non_empty_cell()
330+
self.insert_sharp_comment(col)
331+
332+
def insert_sharp_comment(self, col):
333+
cell_value = self.get_value(col)
334+
new_value = "# " + cell_value
335+
self.change(col, new_value)
336+
337+
def sharp_uncomment(self):
338+
col = self._first_non_empty_cell()
339+
self.remove_sharp_comment(col)
340+
341+
def remove_sharp_comment(self, col):
342+
cell_value = self.get_value(col)
343+
if cell_value.startswith('#'):
344+
new_value = cell_value.lstrip('#').lstrip(' ')
345+
else:
346+
return
347+
self.change(col, new_value)
348+
328349
def _is_commented(self, col):
329350
if self._has_comment_keyword():
330351
return col > self._keyword_column
@@ -380,12 +401,9 @@ def shift_left(self, from_column, delete=False):
380401
from_column -= 1
381402
if not delete and from_column == 0 and cells[from_column] != '':
382403
return
383-
comment = self._get_comment(cells)
384404
if len(cells) > from_column:
385-
if comment:
386-
cells.pop()
387405
cells = cells[:from_column] + cells[from_column + 1:]
388-
self.recreate(cells, comment)
406+
self.recreate(cells)
389407

390408
@staticmethod
391409
def first_non_empty_cell(cells):

src/robotide/editor/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ def on_uncomment_rows(self, event):
242242
_ = event
243243
self.editor.uncomment_rows()
244244

245+
def on_sharp_comment_rows(self, event):
246+
_ = event
247+
self.editor.sharp_comment_rows()
248+
249+
def on_sharp_uncomment_rows(self, event):
250+
_ = event
251+
self.editor.sharp_uncomment_rows()
252+
245253
def on_comment_cells(self, event):
246254
_ = event
247255
self.editor.comment_cells()

src/robotide/editor/editors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ def _collabsible_changed(self, event=None):
182182
self._store_settings_open_status()
183183
self.GetSizer().Layout()
184184
self.Refresh()
185+
self.Parent.GetSizer().Layout()
186+
self.Parent.Refresh()
185187
if event:
186188
event.Skip()
187189

src/robotide/editor/kweditor.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
paste_area, delete_rows, add_rows, comment_rows, insert_cells, delete_cells, \
3434
uncomment_rows, Undo, Redo, RenameKeywordOccurrences, ExtractKeyword, \
3535
add_keyword_from_cells, MoveRowsUp, MoveRowsDown, extract_scalar, extract_list, \
36-
insert_area
36+
insert_area, sharp_comment_rows, sharp_uncomment_rows
3737
from ..editor.cellrenderer import CellRenderer
3838
from ..pluginapi import Plugin
3939
from ..publish import RideItemStepsChanged, RideSaved, PUBLISHER, RideBeforeSaving
@@ -377,6 +377,16 @@ def on_uncomment_rows(self, event=None):
377377
self._resize_grid()
378378
self._skip_except_on_mac(event)
379379

380+
def on_sharp_comment_rows(self, event=None):
381+
self._execute(sharp_comment_rows(self.selection.rows()))
382+
self._resize_grid()
383+
self._skip_except_on_mac(event)
384+
385+
def on_sharp_uncomment_rows(self, event=None):
386+
self._execute(sharp_uncomment_rows(self.selection.rows()))
387+
self._resize_grid()
388+
self._skip_except_on_mac(event)
389+
380390
def on_move_rows_up(self, event=None):
381391
_ = event
382392
self._row_move(MoveRowsUp, -1)
@@ -815,13 +825,23 @@ def _open_cell_editor_and_execute_sharp_uncomment(self):
815825
# Meant for a single cell selection!
816826
wx.CallAfter(self.open_cell_editor().execute_sharp_uncomment)
817827

828+
def current_cell(self):
829+
curcell = [self.GetGridCursorRow(), self.GetGridCursorCol()]
830+
return curcell
831+
818832
def on_comment_cells(self, event):
819833
_ = event
820-
self._open_cell_editor_and_execute_sharp_comment()
834+
if self.GetSelectionBlockTopLeft():
835+
self.on_sharp_comment_rows(event)
836+
else:
837+
self._open_cell_editor_and_execute_sharp_comment()
821838

822839
def on_uncomment_cells(self, event):
823840
_ = event
824-
self._open_cell_editor_and_execute_sharp_uncomment()
841+
if self.GetSelectionBlockTopLeft():
842+
self.on_sharp_uncomment_rows(event)
843+
else:
844+
self._open_cell_editor_and_execute_sharp_uncomment()
825845

826846
def on_cell_right_click(self, event):
827847
self._tooltips.hide()

src/robotide/editor/macroeditors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ def comment_rows(self):
9191
def uncomment_rows(self):
9292
self.kweditor.on_uncomment_rows()
9393

94+
def sharp_comment_rows(self):
95+
self.kweditor.on_sharp_comment_rows()
96+
97+
def sharp_uncomment_rows(self):
98+
self.kweditor.on_sharp_uncomment_rows()
99+
94100
def comment_cells(self):
95101
self.kweditor.on_comment_cells(None)
96102

src/robotide/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
#
1616
# Automatically generated by `tasks.py`.
17-
VERSION = 'v2.0.7dev8'
17+
VERSION = 'v2.0.7dev9'

0 commit comments

Comments
 (0)