Skip to content

Commit 9b94c05

Browse files
Merge pull request #2924 from HelioGuilherme66/autocomplete
Autocomplete
2 parents a854980 + 2fb8834 commit 9b94c05

File tree

20 files changed

+442
-63
lines changed

20 files changed

+442
-63
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
1414
- Added on Text Editor, folding margin with markers style configurable with ``fold symbols`` in settings.cfg.
1515

1616
=== Changed
17+
- Improved autocompletion lists, by using existing words in Test Suite file (still needs more improvements).
1718
- Create directories when needed in New Project dialog.
1819
- Improved the recognition of BDD/Gherkin prefixes when localized in autocomplete on Grid Editor.
1920
- Improved colorization for multiple Gherkin words, for example in the French language.
2021

2122
=== Fixed
22-
23+
- Fixed not set text color on row labels in Grid Editor. Now the General ``secondary foreground`` is applied.
2324
- Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.
2425
- Regression fix from v2.1b1 - Fix wrong item selection, like Test Suite, when doing right-click actions in Project Explorer.
2526
When right clicking over Tree elements, to, for example, expand or select tests, we want to keep the Editor in the same file or position.

src/robotide/application/CHANGELOG.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
</li><li class="listitem">
88
Added on Text Editor, folding margin with markers style configurable with ``fold symbols`` in settings.cfg.
99
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_changed"></a>1.2. Changed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
10+
Improved autocompletion lists, by using existing words in Test Suite file (still needs more improvements).
11+
</li><li class="listitem">
1012
Create directories when needed in New Project dialog.
1113
</li><li class="listitem">
1214
Improved the recognition of BDD/Gherkin prefixes when localized in autocomplete on Grid Editor.
1315
</li><li class="listitem">
1416
Improved colorization for multiple Gherkin words, for example in the French language.
1517
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>1.3. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
18+
Fixed not set text color on row labels in Grid Editor. Now the General ``secondary foreground`` is applied.
19+
</li><li class="listitem">
1620
Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.
1721
</li><li class="listitem">
1822
Regression fix from v2.1b1 - Fix wrong item selection, like Test Suite, when doing right-click actions in Project Explorer.

src/robotide/application/releasenotes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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>Improved autocompletion lists, by using existing words in Test Suite file (still needs more improvements).</li>
172+
<li>Fixed not set text color on row labels in Grid Editor. Now the General <b>secondary foreground</b> is applied.</li>
171173
<li>Added on Text Editor, tab indentation markers and <b>tab markers</b> boolean setting with default <b>True</b>.</li>
172174
<li>Added on Text Editor, folding margin with markers style configurable with <b>fold symbols</b> in settings.cfg.</li>
173175
<li>Create directories when needed in New Project dialog.</li>
@@ -231,7 +233,7 @@ def set_content(self, html_win, content):
231233
<pre class="literal-block">python -m robotide.postinstall -install</pre>
232234
<p>or</p>
233235
<pre class="literal-block">ride_postinstall.py -install</pre>
234-
<p>RIDE {VERSION} was released on 21/February/2025.</p>
236+
<p>RIDE {VERSION} was released on 17/March/2025.</p>
235237
<!-- <br/>
236238
<h3>May The Fourth Be With You!</h3>
237239
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>

src/robotide/controller/macrocontrollers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ def update_namespace(self):
167167
self.datafile_controller.update_namespace()
168168

169169
def get_local_namespace(self):
170-
# print(f"DEBUG: local namespace controller.namespace {self.datafile_controller.namespace}")
171170
return local_namespace(self, self.datafile_controller.namespace)
172171

173172
def get_local_namespace_for_row(self, row):

src/robotide/editor/contentassist.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from wx.lib.filebrowsebutton import FileBrowseButton
2020
from os.path import relpath, dirname, isdir
2121

22+
from .gridbase import GridEditor
2223
from .. import context, utils
2324
from ..context import IS_MAC, IS_WINDOWS, IS_WX_410_OR_HIGHER
2425
from ..namespace.suggesters import SuggestionSource
@@ -74,6 +75,8 @@ def __init__(self, suggestion_source, language='En', **kw):
7475
@staticmethod
7576
def _get_auto_suggestion_config():
7677
from robotide.context import APP
78+
if not APP:
79+
return True
7780
settings = APP.settings['Grid']
7881
return settings.get(_AUTO_SUGGESTION_CFG_KEY, False)
7982

@@ -357,7 +360,8 @@ def __init__(self, parent, plugin, controller, language='En'):
357360
""" According to class MRO, super().__init__ in _ContentAssistTextCtrlBase will init ExpandoTextCtrl
358361
instance """
359362

360-
_ContentAssistTextCtrlBase.__init__(self, SuggestionSource(plugin, controller), language=language,
363+
self.suggestion_source = SuggestionSource(plugin, controller)
364+
_ContentAssistTextCtrlBase.__init__(self, self.suggestion_source, language=language,
361365
parent=parent, size=wx.DefaultSize,
362366
style=wx.WANTS_CHARS | wx.TE_NOHIDESEL)
363367
self.SetBackgroundColour(context.POPUP_BACKGROUND)
@@ -481,9 +485,9 @@ def _get_choices(self, value, row):
481485
@staticmethod
482486
def _get_duplicate_names(choices):
483487
results = set()
484-
normalized_names = [utils.normalize(ch.name) for ch in choices]
488+
normalized_names = [utils.normalize(ch.name if hasattr(ch, 'name') else ch) for ch in choices]
485489
for choice in choices:
486-
normalized = utils.normalize(choice.name)
490+
normalized = utils.normalize(choice.name if hasattr(choice, 'name') else choice)
487491
if normalized_names.count(normalized) > 1:
488492
results.add(normalized)
489493
return results
@@ -493,17 +497,24 @@ def _format_choices(self, choices, prefix, duplicate_names):
493497
choices]
494498

495499
def _format(self, choice, prefix, duplicate_names):
496-
return choice.name if self._matches_unique_shortname(
497-
choice, prefix, duplicate_names) else choice.longname
500+
if hasattr(choice, 'name'):
501+
return choice.name if self._matches_unique_shortname(
502+
choice, prefix, duplicate_names) else choice.longname
503+
elif self._matches_unique_shortname(choice, prefix, duplicate_names):
504+
return choice
498505

499506
@staticmethod
500507
def _matches_unique_shortname(choice, prefix, duplicate_names):
501508
if isinstance(choice, VariableInfo):
502509
return True
503-
if not utils.normalize(choice.name).startswith(
510+
if hasattr(choice, 'name'):
511+
name = choice.name
512+
else:
513+
name = choice
514+
if not utils.normalize(name).startswith(
504515
utils.normalize(prefix)):
505516
return False
506-
if utils.normalize(choice.name) in duplicate_names:
517+
if utils.normalize(name) in duplicate_names:
507518
return False
508519
return True
509520

@@ -532,8 +543,11 @@ def content_assist_for(self, value, row=None):
532543
self._choices = self._suggestions.get_for(value, row=row)
533544
if not self._choices:
534545
self._list.ClearAll()
535-
self._parent.hide()
546+
if not isinstance(self._parent, GridEditor):
547+
self._parent.hide()
536548
return False
549+
self._choices = list(set([c for c in self._choices if c is not None]))
550+
# print(f"DEBUG: contentassist.py ContentAssistPopup content_assist_for CALL POPULATE Choices={self._choices}")
537551
self._list.populate(self._choices)
538552
return True
539553

@@ -616,7 +630,7 @@ def on_list_item_activated(self, event):
616630
def on_list_item_selected(self, event):
617631
self._selection = event.GetIndex()
618632
item = self._suggestions.get_item(event.GetText())
619-
if item.details:
633+
if hasattr(item, 'details') and item.details:
620634
self._details_popup.Show()
621635
self._details_popup.set_content(item.details, item.name)
622636
elif self._details_popup.IsShown():

src/robotide/editor/gridbase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def __init__(self, parent, num_rows, num_cols, popup_creator=None):
6161
self.GetGridColLabelWindow().SetForegroundColour(Colour(self.color_secondary_foreground))
6262
self.GetGridRowLabelWindow().SetBackgroundColour(Colour(self.color_secondary_background))
6363
self.GetGridRowLabelWindow().SetForegroundColour(Colour(self.color_secondary_foreground))
64+
self.SetLabelBackgroundColour(Colour(self.color_secondary_background))
65+
self.SetLabelTextColour(Colour(self.color_secondary_foreground))
6466
self._popup_creator = popup_creator or PopupCreator()
6567
"""
6668
DEBUG: This block adds aditional scrollbars in mains Grid Editor, making hard to focus on cells keeping the

src/robotide/editor/kweditor.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,32 @@ def is_json(json_str):
12131213
return False
12141214
return True
12151215

1216+
"""
1217+
def words_cache(self, doc_size: int):
1218+
if doc_size != self.doc_size:
1219+
words_list = self.collect_words(SOME_CONTENT)
1220+
self._words_cache.update(words_list)
1221+
self.doc_size = doc_size
1222+
return sorted(self._words_cache)
1223+
1224+
@staticmethod
1225+
def collect_words(text: str):
1226+
if not text:
1227+
return ['']
1228+
1229+
def var_strip(txt:str):
1230+
return txt.strip('$&@%{[(')
1231+
1232+
words = set()
1233+
words_ = list(text.replace('\r\n', ' ').replace('\n', ' ').split(' '))
1234+
for w in words_:
1235+
wl = var_strip(w)
1236+
if wl and wl[0].isalpha():
1237+
words.add(w)
1238+
1239+
print(f"DEBUG: texteditor.py SourceEditor collect_words returning {words=}")
1240+
return sorted(words)
1241+
"""
12161242

12171243
class ContentAssistCellEditor(GridCellEditor):
12181244

@@ -1257,6 +1283,7 @@ def execute_sharp_uncomment(self):
12571283

12581284
def Create(self, parent, idd, evthandler):
12591285
self._tc = ExpandingContentAssistTextCtrl(parent, self._plugin, self._controller, self._language)
1286+
# self._tc.suggestion_source.update_from_local(self._controller.datafile, self._language)
12601287
self.SetControl(self._tc)
12611288
if evthandler:
12621289
self._tc.PushEventHandler(evthandler)

0 commit comments

Comments
 (0)