Skip to content

Commit d8ab1ad

Browse files
Improve auto complete in Gid Editor. WIP
1 parent 8b0a4e1 commit d8ab1ad

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/robotide/editor/contentassist.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
from operator import index
1516

1617
import wx
1718
from wx import Colour
@@ -274,10 +275,26 @@ def on_focus_lost(self, event, set_value=True):
274275
self.hide()
275276

276277
def fill_suggestion(self):
278+
initial_value = self.GetValue()
279+
popup_value = self._popup.get_value()
280+
# print(f"DEBUG: contentassist.py ContentAssistTextCtrlBase fill_suggestion initial_value={initial_value} \n"
281+
# f"popup_value={popup_value}")
282+
if popup_value.lower() in initial_value.lower():
283+
initial_value = initial_value.replace(initial_value, '')
284+
parts = initial_value.split()
285+
for p in parts:
286+
if popup_value.lower().startswith(p.strip('}])').lower()):
287+
idx = initial_value.index(p)
288+
initial_value = initial_value[:idx]
289+
# print(f"DEBUG: contentassist.py ContentAssistTextCtrlBase fill_suggestion FOUND p={p} "
290+
# f"new initial_value={initial_value}")
291+
break
277292
if self.gherkin_prefix:
278-
value = self.gherkin_prefix + self._popup.get_value() or self.GetValue()
293+
initial_value = initial_value.replace(self.gherkin_prefix,'') # Should be left replace
294+
value = self.gherkin_prefix + initial_value + popup_value # or self.GetValue()
279295
else:
280-
value = self._popup.get_value() or self.GetValue()
296+
value = initial_value + popup_value # or self.GetValue()
297+
print(f"DEBUG: contentassist.py ContentAssistTextCtrlBase fill_suggestion writting value={value}")
281298
if value:
282299
wrapper_view = self.GetParent().GetParent()
283300
if hasattr(wrapper_view, 'open_cell_editor'):

src/robotide/namespace/suggesters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def get_suggestions(self, value, row=None):
3333
# If we have a space separated value, try first the value and then the last word
3434
key = start.split(' ')[-1]
3535
keys = [start, key] if start != key else [start]
36+
for var in ['$', '${', '@{', '&{']:
37+
if not key.startswith(var):
38+
keys.append(f"{var}{key}")
3639
sugs = set()
3740
for initial in keys:
3841
if self._controller:

utest/editor/test_z_kweditor_plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def OnInit(self): # Overrides wx method
206206
return True
207207

208208
def _datafile_controller(self):
209-
return data_controller(new_test_case_file(datafilereader.TESTCASEFILE_WITH_EVERYTHING), self.project)
209+
return data_controller(new_test_case_file(datafilereader.SIMPLE_PROJECT), self.project)
210210

211211
def OnExit(self): # Overrides wx method
212212
if hasattr(self, 'file_settings'):
@@ -228,7 +228,7 @@ def setUp(self):
228228
ShortcutRegistry(self.frame))
229229
self.frame.tree = Tree(self.frame, self.frame.actions, self.settings)
230230
self.app.project = Project(self.app.namespace, self.app.settings)
231-
self.app.project.load_datafile(datafilereader.TESTCASEFILE_WITH_EVERYTHING, MessageRecordingLoadObserver())
231+
self.app.project.load_datafile(datafilereader.SIMPLE_PROJECT, MessageRecordingLoadObserver())
232232
self.app.model = self.app.project.data
233233
self.panel = self.app.panel
234234
self.namespace = self.app.project.namespace
@@ -283,7 +283,7 @@ def _no_item_selected_plugin(self):
283283
return FakePlugin(self._registered_editors, None)
284284

285285
def _datafile_controller(self):
286-
return data_controller(new_test_case_file(datafilereader.TESTCASEFILE_WITH_EVERYTHING), self.app.project)
286+
return data_controller(new_test_case_file(datafilereader.SIMPLE_PROJECT), self.app.project)
287287

288288
def tearDown(self):
289289
self.shared_mem.shm.close()

0 commit comments

Comments
 (0)