Skip to content

Commit

Permalink
Improve content assistance in Text Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 committed Oct 5, 2023
1 parent c7dfd71 commit 1da9c1c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni

=== Changed

- Improved content assistance in Text Editor by allowing to filter list as we type
- Improved file changes detection to only consider valid formats
- Improved keyword ``Find Usages`` to return more matches. Fails to find mixed spaces and ``_``
- In Grid Editor ``Ctrl-Shift-4`` now replaces escaped spaces ``\\ `` by spaces
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/application/CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</li><li class="listitem">
Added support for JSON variables, by using the installed Robot Framework import method
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>1.2. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Fixed resource files dissapearing from Project tree on Windows
<li class="listitem">Improved content assistance in Text Editor by allowing to filter list as we type
</li><li class="listitem">Fixed resource files dissapearing from Project tree on Windows
</li><li class="listitem">
Fixed missing indication of link for User Keyword, when pressing ``Ctrl`` in Grid Editor
</li><li class="listitem">
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def set_content(self, html_win, content):
</ul>
<p><strong>New Features and Fixes Highlights</strong></p>
<ul class="simple">
<li>Improved content assistance in Text Editor by allowing to filter list as we type</li>
<li>Fixed resource files dissapearing from Project tree on Windows</li>
<li>Fixed missing indication of link for User Keyword, when pressing <b>Ctrl</b> in Grid Editor</li>
<li>Added content help pop-up on Text Editor by pressing <b>Ctrl</b> for text at cursor position or selected autocomplete list item</li>
Expand Down Expand Up @@ -239,6 +240,6 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 23/Sep/2023.</p>
<p>RIDE {VERSION} was released on 5/Oct/2023.</p>
</div>
"""
25 changes: 8 additions & 17 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,19 +647,23 @@ def on_content_assist(self, event):
selected = self.source_editor.get_selected_or_near_text()
self.set_editor_caret_position()
sugs = []
length_entered = 0
if selected:
for start in selected:
sugs.extend(s.name for s in self._suggestions.get_suggestions(start))
# DEBUG: Here, if sugs is still [], then we can get all words from line and repeat suggestions
# In another evolution, we can use database of words by frequency (considering future by project db)
sel = [s for s in selected] if selected else []
entry_word = sel[0].split('.')[-1].strip()
length_entered = len(entry_word) # Because Libraries prefixed
sugs.extend(s.name for s in self._suggestions.get_suggestions(''))
if len(sugs) > 0:
sugs = [s for s in sugs if s != '']
if sugs:
self.source_editor.AutoCompSetDropRestOfWord(False)
self.source_editor.AutoCompSetIgnoreCase(True)
self.source_editor.AutoCompSetSeparator(ord(';'))
self.source_editor.AutoCompShow(0, ";".join(sugs))
self.source_editor.AutoCompShow(length_entered, ";".join(sugs))
self.autocomp_pos = self.source_editor.AutoCompPosStart()
self._showing_list = True
# DEBUG: self.set_editor_caret_position()
Expand Down Expand Up @@ -1047,8 +1051,8 @@ def on_key_down(self, event):
self.source_editor.hide_kw_doc()
if event.GetKeyCode() == wx.WXK_TAB and not event.ControlDown() and not event.ShiftDown():
if self._showing_list: # Allows to use Tab for keyword selection
print(f"DEBUG: textedit on_key_down at autocomplete, caret={self.autocomp_pos}"
f" text is={self.source_editor.AutoCompGetCurrentText()}")
self._showing_list = False
wx.CallAfter(self.write_ident) # DEBUG: Make this configurable?
event.Skip()
return
selected = self.source_editor.GetSelection()
Expand All @@ -1072,6 +1076,7 @@ def on_key_down(self, event):
self.auto_indent()
else:
self._showing_list = False
wx.CallAfter(self.write_ident) # DEBUG: Make this configurable?
event.Skip()
elif keycode in (ord('1'), ord('2'), ord('5')) and event.ControlDown():
self.execute_variable_creator(list_variable=(keycode == ord('2')),
Expand Down Expand Up @@ -1252,28 +1257,14 @@ def delete_row(self, event):
_ = event
start, end = self.source_editor.GetSelection()
ini_line = self.source_editor.LineFromPosition(start)
begpos = self.source_editor.PositionFromLine(ini_line)
self.source_editor.SelectNone()
if start == end:
end_line = ini_line
# Delete is not working without selected content
# self.source_editor.SetSelection(start, start+1)
else:
end_line = self.source_editor.LineFromPosition(end)
for _ in range(ini_line, end_line + 1):
self.source_editor.GotoLine(ini_line)
self.source_editor.LineDelete()
# cursor position when doing block select is always the end of the selection
"""
if ini_line != end_line:
self.source_editor.SetCurrentPos(begpos)
self.source_editor.SetInsertionPoint(begpos)
self.source_editor.SetAnchor(begpos)
else:
self.source_editor.SetCurrentPos(cursor)
self.source_editor.SetInsertionPoint(cursor)
self.source_editor.SetAnchor(cursor)
"""
self.store_position()

def insert_row(self, event):
Expand Down

0 comments on commit 1da9c1c

Please sign in to comment.