Skip to content

Commit 8a8918a

Browse files
Improve code. Fix auto_indent in Text Editor (#2583)
1 parent 17ec6fa commit 8a8918a

26 files changed

+794
-772
lines changed

CHANGELOG.adoc

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

1313
- Added the note, 'Colors will be active after next RIDE restart.' to the Preferences of Test Runner.
1414

15+
== Fixed
16+
17+
- Fixed auto-indent on block commands in Text Editor
18+
1519
== https://github.com/robotframework/RIDE/blob/master/doc/releasenotes/ride-2.0.3.rst[2.0.3] - 2023-04-16
1620

1721
=== Changed

README.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ See the https://github.com/robotframework/RIDE/blob/master/doc/releasenotes/ride
2323
**Version https://github.com/robotframework/RIDE/tree/release/1.7.4.2[1.7.4.2] was the last release supporting Python 2.7**
2424

2525

26-
**The current development version is based on 2.0.3, supports Python from 3.6 up to 3.10 (16th April 2023).**
26+
**The current development version is based on 2.0.4, supports Python from 3.6 up to 3.10 (30th April 2023).**
2727

2828
Currently the unit tests are only tested on Python 3.10 (which is the recommended version).
2929
Likewise, the current version of wxPython, is 4.2.0, but RIDE is known to work with 4.0.7 and 4.1.1 versions.
3030

31-
(3.6 < python < 3.11) Install current released version (**2.0.3**) with:
31+
(3.6 < python < 3.11) Install current released version (**2.0.4**) with:
3232
[source, shell]
3333
pip install -U robotframework-ride
34-
35-
Install current development version (**2.0.3**) with:
34+
Install current development version (**2.0.4**) with:
3635
[source, shell]
3736
pip install -U https://github.com/robotframework/RIDE/archive/master.zip
3837

src/robotide/application/CHANGELOG.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="idm45643391479856"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="idm45643391479856"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
33
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
44
Added the note, <span class="emphasis"><em>Colors will be active after next RIDE restart.</em></span> to the Preferences of Test Runner.
5+
</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_fixed"></a>3. Fixed</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
6+
<li class="listitem">
7+
Fixed auto-indent on block commands in Text Editor
58
</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_blob_master_doc_releasenotes_ride_2_0_3_rst_2_0_3_ulink_2023_04_16"></a>2. <a class="ulink" href="https://github.com/robotframework/RIDE/blob/master/doc/releasenotes/ride-2.0.3.rst" target="_top">2.0.3</a> - 2023-04-16</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_changed"></a>2.1. Changed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
69
Allow to do auto-suggestions of keywords in grid editor without a shortcut, if you want to enable or disable this feature you can config in <code class="literal">Preferences -&gt; Grid Editor -&gt; Enable auto suggestions</code>
710
</li><li class="listitem">
811
Made ``\\n`` visible when editing cells in Grid Editor (problematic in Windows)
9-
</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_fixed"></a>3. Fixed</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
12+
</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_fixed"></a>3. Fixed</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
13+
<li class="listitem">
1014
Fixed missing auto-enclosing when in Cell Editor in Linux
1115
</li><li class="listitem">
1216
Fixed RIDE will crash when using third party input method in Mac OS

src/robotide/application/releasenotes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def set_content(self, html_win, content):
117117

118118
date = time.strftime('%d/%m/%Y', time.localtime(os.path.getmtime(__file__)))
119119
version = VERSION
120-
milestone = re.split('[ab-]', VERSION)[0]
120+
# milestone = re.split('[ab-]', VERSION)[0]
121121

122122
WELCOME_TEXT = f"""
123123
<h2>Welcome to use RIDE version {version}</h2>
@@ -145,7 +145,7 @@ def set_content(self, html_win, content):
145145
146146
147147
<p><a class="reference external" href="https://github.com/robotframework/RIDE/">RIDE (Robot Framework IDE)</a>
148-
v{VERSION} is a new release with minor enhancements and bug fixes. The reference for valid arguments is
148+
{VERSION} is a new release with minor enhancements and bug fixes. The reference for valid arguments is
149149
<a class="reference external" href="http://robotframework.org">Robot Framework</a> installed version, which is at this
150150
moment 6.0.2. However, internal library is based on version 3.1.2, to keep compatibility with old formats.</p>
151151
<p></p>
@@ -167,7 +167,7 @@ def set_content(self, html_win, content):
167167
<li>Keywords auto-suggestion in grid editor does not need shortcut anymore, if you want to enable or disable this
168168
feature you can config in `Preferences -> Grid Editor -> Enable auto suggestions`</li>
169169
170-
<li>Made <pre>\\n</pre> visible when editing cells in Grid Editor (problematic in Windows)</li>
170+
<li>Made \\n visible when editing cells in Grid Editor (problematic in Windows)</li>
171171
172172
<li>Fixed missing auto-enclosing when in Cell Editor in Linux</li>
173173
@@ -232,6 +232,6 @@ def set_content(self, html_win, content):
232232
<pre class="literal-block">
233233
python -m robotide.postinstall -install
234234
</pre>
235-
<p>RIDE v{VERSION} was released on 16/Apr/2023.</p>
235+
<p>RIDE {VERSION} was released on 16/Apr/2023.</p>
236236
</div>
237237
"""

src/robotide/contrib/testrunner/testrunnerplugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ def _get_app_settings(parent):
12921292
if not parent:
12931293
raise ValueError('Value does not contain NoteBook as parent')
12941294
if isinstance(parent, NoteBook):
1295-
return parent._app.settings
1295+
return parent.app.settings
12961296
parent = parent.GetParent()
12971297

12981298

src/robotide/controller/basecontroller.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,56 +69,56 @@ def is_modifiable(self):
6969

7070

7171
class WithNamespace(object):
72-
_namespace = None # Ensure namespace exists
72+
namespace = None # Ensure namespace exists
7373

7474
def _set_namespace_from(self, controller):
75-
self._set_namespace(controller._namespace)
75+
self._set_namespace(controller.namespace)
7676

7777
def _set_namespace(self, namespace):
78-
self._namespace = namespace
78+
self.namespace = namespace
7979

8080
def get_namespace(self):
81-
return self._namespace
81+
return self.namespace
8282

8383
def update_namespace(self):
84-
if not self._namespace:
84+
if not self.namespace:
8585
return
86-
self._namespace.update()
86+
self.namespace.update()
8787

8888
def register_for_namespace_updates(self, listener):
89-
if not self._namespace:
89+
if not self.namespace:
9090
return
91-
self._namespace.register_update_listener(listener)
91+
self.namespace.register_update_listener(listener)
9292

9393
def unregister_namespace_updates(self, listener):
94-
if not self._namespace:
94+
if not self.namespace:
9595
return
96-
self._namespace.unregister_update_listener(listener)
96+
self.namespace.unregister_update_listener(listener)
9797

9898
def clear_namespace_update_listeners(self):
99-
self._namespace.clear_update_listeners()
99+
self.namespace.clear_update_listeners()
100100

101101
def is_user_keyword(self, datafile, value):
102-
return self._namespace.is_user_keyword(datafile, value)
102+
return self.namespace.is_user_keyword(datafile, value)
103103

104104
def is_library_keyword(self, datafile, value):
105-
return self._namespace.is_library_keyword(datafile, value)
105+
return self.namespace.is_library_keyword(datafile, value)
106106

107107
def get_all_keywords_from(self, *datafiles):
108-
return self._namespace.get_all_keywords(*datafiles)
108+
return self.namespace.get_all_keywords(*datafiles)
109109

110110
def get_all_cached_library_names(self):
111-
return self._namespace.get_all_cached_library_names()
111+
return self.namespace.get_all_cached_library_names()
112112

113113
def keyword_info(self, datafile, keyword_name):
114-
return self._namespace.find_keyword(datafile, keyword_name)
114+
return self.namespace.find_keyword(datafile, keyword_name)
115115

116116
def is_library_import_ok(self, imp):
117-
return self._namespace.is_library_import_ok(self.datafile, imp)
117+
return self.namespace.is_library_import_ok(self.datafile, imp)
118118

119119
def is_variables_import_ok(self, imp):
120120
# print("DEBUG: BaseController is_variables_import_ok %s\n" % imp.name)
121-
return self._namespace.is_variables_import_ok(self.datafile, imp)
121+
return self.namespace.is_variables_import_ok(self.datafile, imp)
122122

123123

124124
class WithUndoRedoStacks(object):

src/robotide/controller/ctrlcommands.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ def change_steps(self, context):
10281028
step.change(self._col, self._value, not self._insert)
10291029
# print(f"DEBUG: change_steps after change from_column: ({self._row}, {self._col}, {self._value}) Line: {context.steps[self._row].as_list()}")
10301030
self._step(context).remove_empty_columns_from_end(not self._insert)
1031-
# value = self._step(context).get_value(self._col).strip()
1031+
# value = self.step_controller_step(context).get_value(self._col).strip()
10321032
# print(f"DEBUG: change_steps after change from_column: value={value} self.value = {self._value}")
10331033
# DEGUG: Next validation is not possible to call when the step is Indented
10341034
# assert self._validate_postcondition(context), 'Should have correct value after change'
@@ -1123,7 +1123,7 @@ def change_steps(self, context, delete=False):
11231123
self._step(context).shift_right(self._col, delete=delete)
11241124
if not delete:
11251125
# print(f"DEBUG: InsertCell change_steps row:{self._row} cols:{self._col} row BEFORE _recreate: {context.steps[self._row].as_list()}"
1126-
# f"\ntype step={type(self._step(context))}")
1126+
# f"\ntype step={type(self.step_controller_step(context))}")
11271127
self._step(context)._recreate(context.steps[self._row].as_list())
11281128
assert self._step(context).get_value(self._col) == '', 'Should have an empty value after insert'
11291129
return True
@@ -1225,16 +1225,16 @@ def _get_undo_command(self):
12251225
return CommentRow(self._row)
12261226

12271227

1228-
_INDENTED_INNER = ['ELSE', 'ELSE IF', 'EXCEPT', 'FINALLY']
1229-
_INDENTED_START = ['FOR', 'IF', 'WHILE', 'TRY'] + _INDENTED_INNER
1228+
INDENTED_INNER = ['ELSE', 'ELSE IF', 'EXCEPT', 'FINALLY']
1229+
INDENTED_START = ['FOR', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER
12301230

12311231

12321232
def is_indent_start(cell):
1233-
return cell in _INDENTED_START
1233+
return cell in INDENTED_START
12341234

12351235

12361236
def is_indent_inner(cell):
1237-
return cell in _INDENTED_INNER
1237+
return cell in INDENTED_INNER
12381238

12391239

12401240
class MoveRowsUp(_StepsChangingCommand):
@@ -1277,32 +1277,32 @@ def non_empty_from_left(line):
12771277
pre_prev_col = non_empty_from_left(pre_prev_row)
12781278
next_cell_row = row + 1 if row + 1 < number_of_steps_before else row
12791279
next_row_col = non_empty_from_left(next_cell_row)
1280-
add_indent = pre_prev_col > index and ( not is_indent_inner(context.steps[row].as_list()[index]) and
1281-
context.steps[row]._step.cells[index] != 'END' or
1282-
is_indent_start(context.steps[pre_prev_row]._step.cells[pre_prev_col]))
1283-
del_indent = (prev_cell > index and context.steps[row]._step.cells[index] == 'END') or\
1284-
(pre_prev_col < index and not is_indent_start(context.steps[pre_prev_row]._step.cells[pre_prev_col])) or\
1285-
(prev_cell < index and not is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell]))
1280+
add_indent = pre_prev_col > index and (not is_indent_inner(context.steps[row].as_list()[index]) and
1281+
context.steps[row].step_controller_step.cells[index] != 'END' or
1282+
is_indent_start(context.steps[pre_prev_row].step_controller_step.cells[pre_prev_col]))
1283+
del_indent = (prev_cell > index and context.steps[row].step_controller_step.cells[index] == 'END') or \
1284+
(pre_prev_col < index and not is_indent_start(context.steps[pre_prev_row].step_controller_step.cells[pre_prev_col])) or \
1285+
(prev_cell < index and not is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell]))
12861286
del_prev_indent = (pre_prev_col < prev_cell) and (
1287-
is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell]))
1287+
is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell]))
12881288
if is_indent_start(context.steps[row].as_list()[index]) or add_indent:
12891289
# print(f"DEBUG: MoveRowsUp IS_INDENT_START: {row=} {context.steps[row].as_list()}\n "
12901290
# f"{del_indent=} {add_indent=} {prev_cell=} {prev_cell_row=} {pre_prev_col=}"
12911291
# f"{del_prev_indent=} {index=} {next_cell_row=} {next_row_col=} ")
12921292
new_next_indent = (prev_cell == index and
1293-
(not is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell])
1294-
and context.steps[prev_cell_row]._step.cells[prev_cell] != 'END')) or (
1295-
next_row_col > prev_cell and is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell])
1293+
(not is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell])
1294+
and context.steps[prev_cell_row].step_controller_step.cells[prev_cell] != 'END')) or (
1295+
next_row_col > prev_cell and is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell])
12961296
) or (not is_indent_inner(context.steps[row].as_list()[index]) and
1297-
context.steps[next_cell_row]._step.cells[next_row_col] != 'END' and next_row_col < index)
1297+
context.steps[next_cell_row].step_controller_step.cells[next_row_col] != 'END' and next_row_col < index)
12981298
else:
1299-
new_next_indent = (pre_prev_col > next_row_col and context.steps[row]._step.cells[index] != 'END'
1300-
and prev_cell < index ) or (
1299+
new_next_indent = (pre_prev_col > next_row_col and context.steps[row].step_controller_step.cells[index] != 'END'
1300+
and prev_cell < index) or (
13011301
next_row_col > prev_cell and
1302-
is_indent_start(context.steps[next_cell_row]._step.cells[next_row_col])
1303-
and not is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell]))
1304-
new_next_deindent = (prev_cell > index and context.steps[row]._step.cells[index] == 'END')
1305-
keep_indent = not add_indent and pre_prev_col == index and context.steps[next_cell_row]._step.cells[next_row_col] == 'END'
1302+
is_indent_start(context.steps[next_cell_row].step_controller_step.cells[next_row_col])
1303+
and not is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell]))
1304+
new_next_deindent = (prev_cell > index and context.steps[row].step_controller_step.cells[index] == 'END')
1305+
keep_indent = not add_indent and pre_prev_col == index and context.steps[next_cell_row].step_controller_step.cells[next_row_col] == 'END'
13061306
context.move_step_up(row)
13071307
new_index = non_empty_from_left(prev_cell_row)
13081308
if new_next_deindent:
@@ -1318,19 +1318,19 @@ def non_empty_from_left(line):
13181318
if keep_indent and new_index > index:
13191319
for _ in range(index, new_index):
13201320
context.steps[prev_cell_row].shift_left(0, delete=False)
1321-
if add_indent and (not is_indent_start(context.steps[prev_cell_row]._step.cells[prev_cell]) and
1322-
context.steps[row]._step.cells[index] != 'END') or new_next_indent:
1321+
if add_indent and (not is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[prev_cell]) and
1322+
context.steps[row].step_controller_step.cells[index] != 'END') or new_next_indent:
13231323
context.steps[row].shift_right(0)
1324-
if add_indent and not is_indent_start(context.steps[prev_cell_row]._step.cells[pre_prev_col]):
1324+
if add_indent and not is_indent_start(context.steps[prev_cell_row].step_controller_step.cells[pre_prev_col]):
13251325
context.steps[prev_cell_row].shift_right(0) # new_next_indent and\
13261326
if (del_indent and not keep_indent) or \
1327-
(keep_indent and context.steps[prev_cell_row]._step.cells[index] == 'END'
1328-
and not is_indent_start(context.steps[row]._step.cells[index])):
1327+
(keep_indent and context.steps[prev_cell_row].step_controller_step.cells[index] == 'END'
1328+
and not is_indent_start(context.steps[row].step_controller_step.cells[index])):
13291329
context.steps[prev_cell_row].shift_left(0, delete=False)
13301330
if del_prev_indent and not keep_indent:
13311331
context.steps[prev_cell_row].shift_left(0, delete=False)
1332-
if keep_indent and prev_cell > index and len(context.steps[prev_cell_row]._step.cells) > prev_cell and\
1333-
context.steps[prev_cell_row]._step.cells[prev_cell] == 'END':
1332+
if keep_indent and prev_cell > index and len(context.steps[prev_cell_row].step_controller_step.cells) > prev_cell and\
1333+
context.steps[prev_cell_row].step_controller_step.cells[prev_cell] == 'END':
13341334
context.steps[prev_cell_row].shift_left(0, delete=False)
13351335
assert len(context.steps) == number_of_steps_before
13361336
return True

0 commit comments

Comments
 (0)