From c96bdde012bcf6b2ad497d717e7cf1a4aca55da6 Mon Sep 17 00:00:00 2001 From: HelioGuilherme66 Date: Wed, 11 Oct 2023 01:26:41 +0100 Subject: [PATCH 1/2] Fixes show keyword doc in Text Editor for Gherkin keywords --- src/robotide/editor/texteditor.py | 3 +++ src/robotide/version.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/robotide/editor/texteditor.py b/src/robotide/editor/texteditor.py index c478b2d5b..9b9073ed5 100644 --- a/src/robotide/editor/texteditor.py +++ b/src/robotide/editor/texteditor.py @@ -388,6 +388,7 @@ def __init__(self, plugin, parent, title, data_validator): self._data_validator.set_editor(self) self.source_editor_parent = parent self.plugin = plugin + self.datafile = None self._title = title self.tab_size = self.source_editor_parent.app.settings.get(TXT_NUM_SPACES, 4) self.reformat = self.source_editor_parent.app.settings.get('reformat', False) @@ -667,6 +668,8 @@ def open(self, data): except IndexError: # It is a new project, no content yet self._controller_for_context = DummyController(self._data.wrapper_data, self._data.wrapper_data) self._suggestions = SuggestionSource(None, self._controller_for_context) + if self.plugin.datafile: + self.datafile = self.plugin.datafile if not self.source_editor: self._stored_text = self._data.content else: diff --git a/src/robotide/version.py b/src/robotide/version.py index db3167d90..43232babe 100644 --- a/src/robotide/version.py +++ b/src/robotide/version.py @@ -14,4 +14,4 @@ # limitations under the License. # # Automatically generated by `tasks.py`. -VERSION = 'v2.0.8dev20' +VERSION = 'v2.0.8dev21' From 67e8213a7befaf28fd1b3ed187389b8acb210f33 Mon Sep 17 00:00:00 2001 From: HelioGuilherme66 Date: Thu, 12 Oct 2023 01:53:48 +0100 Subject: [PATCH 2/2] Fix double actions on Text Editor --- src/robotide/editor/texteditor.py | 40 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/robotide/editor/texteditor.py b/src/robotide/editor/texteditor.py index 9b9073ed5..df59a4f21 100644 --- a/src/robotide/editor/texteditor.py +++ b/src/robotide/editor/texteditor.py @@ -92,9 +92,10 @@ def f(event): if IS_WINDOWS or IS_MAC: # Linux does not need this key binding self.register_shortcut('CtrlCmd-V', focused(lambda e: self._editor.paste())) self.register_shortcut('CtrlCmd-S', focused(lambda e: self.on_saving(e))) - self.register_shortcut('CtrlCmd-F', lambda e: self._editor.search_field.SetFocus()) - self.register_shortcut('CtrlCmd-G', lambda e: self._editor.on_find(e)) - self.register_shortcut('CtrlCmd-Shift-G', lambda e: self._editor.on_find_backwards(e)) + self.register_shortcut('CtrlCmd-F', focused(lambda e: self._editor.search_field.SetFocus())) + # To avoid double actions these moved to on_key_down + # self.register_shortcut('CtrlCmd-G', focused(lambda e: self._editor.on_find(e))) + # self.register_shortcut('CtrlCmd-Shift-G', focused(lambda e: self._editor.on_find_backwards(e))) self.register_shortcut('Ctrl-Space', lambda e: focused(self._editor.on_content_assist(e))) self.register_shortcut('CtrlCmd-Space', lambda e: focused(self._editor.on_content_assist(e))) self.register_shortcut('Alt-Space', lambda e: focused(self._editor.on_content_assist(e))) @@ -538,11 +539,11 @@ def dirty(self): def datafile_controller(self): return self._data.wrapper_data if self._data else None - def on_find(self, event): + def on_find(self, event, forward=True): if self.source_editor: text = self.source_editor.GetSelectedText() - if len(text) > 0 and text.lower() != self.search_field.GetValue().lower() and \ - event.GetEventType() == wx.wxEVT_TOOL: + if (len(text) > 0 and text.lower() != self.search_field.GetValue().lower() and + event.GetEventType() != wx.wxEVT_TOOL): # if a search string selected in text and CTRL+G is pressed # put the string into the search_field self.search_field.SelectAll() @@ -551,17 +552,16 @@ def on_find(self, event): self.search_field.SetValue(text) self.search_field.SelectAll() self.search_field.Update() - # and set the start position to the beginning of the editor - self.source_editor.SetAnchor(0) - self.source_editor.SetCurrentPos(0) - self.source_editor.Update() - - self._find() + if forward: + # and set the start position to the beginning of the editor + self.source_editor.SetAnchor(0) + self.source_editor.SetCurrentPos(0) + self.source_editor.Update() + self._find(forward) def on_find_backwards(self, event): - _ = event if self.source_editor: - self._find(forward=False) + self.on_find(event, forward=False) def _find(self, forward=True): txt = self.search_field.GetValue().encode('utf-8') @@ -932,8 +932,10 @@ def paste(self): focus = wx.Window.FindFocus() if focus == self.source_editor: self.source_editor.Paste() + """ DEBUG: It was double pasting in search_field elif focus == self.search_field: self.search_field.Paste() + """ self._mark_file_dirty(self.source_editor.GetModify()) def select_all(self): @@ -1062,6 +1064,12 @@ def on_key_down(self, event): and event.ControlDown() and not event.ShiftDown()): # We need to ignore this in Linux, because it does double-action return + elif keycode in (ord('g'), ord('G')) and event.ControlDown(): + if event.ShiftDown(): + wx.CallAfter(self.on_find_backwards, event) + else: + wx.CallAfter(self.on_find, event) + return elif keycode in (ord('d'), ord('D')) and event.ControlDown() and not event.ShiftDown(): # We need to ignore because Scintilla does Duplicate line return @@ -1127,7 +1135,7 @@ def _start_kw_doc_timer(self): def execute_variable_creator(self, list_variable=False, dict_variable=False): from_, to_ = self.source_editor.GetSelection() - text = self.source_editor.SelectedText + text = self.source_editor.GetSelectedText() size = len(bytes(text, encoding='utf-8')) to_ = from_ + size if list_variable: @@ -1154,7 +1162,7 @@ def _variable_creator_value(symbol, value=''): def execute_enclose_text(self, keycode): from_, to_ = self.source_editor.GetSelection() - text = self.source_editor.SelectedText + text = self.source_editor.GetSelectedText() size = len(bytes(text, encoding='utf-8')) to_ = from_ + size if size == 0: