From bc4d96bc3f73a2bd30cb25b451e661f1d52a8e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 26 Mar 2020 15:54:52 +0100 Subject: [PATCH] [apps/code] Reload the variable box less often --- apps/code/editor_controller.cpp | 7 ++++--- apps/code/editor_view.cpp | 4 ++++ apps/code/editor_view.h | 1 + apps/code/python_text_area.h | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/code/editor_controller.cpp b/apps/code/editor_controller.cpp index 3e5cc408b..dd4eadba1 100644 --- a/apps/code/editor_controller.cpp +++ b/apps/code/editor_controller.cpp @@ -124,9 +124,10 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events: VariableBoxController * EditorController::variableBoxForInputEventHandler(InputEventHandler * textInput) { VariableBoxController * varBox = App::app()->variableBoxController(); - int length = 0; - const char * text = m_editorView.textToAutocomplete(&length); - varBox->loadFunctionsAndVariables(m_scriptIndex, text, length); + // If the editor is autocompleting, the variable box has already been loaded + if (!m_editorView.isAutocompleting()) { + varBox->loadFunctionsAndVariables(m_scriptIndex, nullptr, 0); + } return varBox; } diff --git a/apps/code/editor_view.cpp b/apps/code/editor_view.cpp index 0e174f95e..f16bfec21 100644 --- a/apps/code/editor_view.cpp +++ b/apps/code/editor_view.cpp @@ -20,6 +20,10 @@ const char * EditorView::textToAutocomplete(int * length) const { return m_textArea.textToAutocomplete(length); } +bool EditorView::isAutocompleting() const { + return m_textArea.isAutocompleting(); +} + void EditorView::resetSelection() { m_textArea.resetSelection(); } diff --git a/apps/code/editor_view.h b/apps/code/editor_view.h index 24455c48d..2093bcc3d 100644 --- a/apps/code/editor_view.h +++ b/apps/code/editor_view.h @@ -10,6 +10,7 @@ class EditorView : public Responder, public View, public ScrollViewDelegate { public: EditorView(Responder * parentResponder, App * pythonDelegate); + bool isAutocompleting() const; /* Returns the beginning of the text to autocomplete, and loads its length in * the method parameter length */ const char * textToAutocomplete(int * length) const; diff --git a/apps/code/python_text_area.h b/apps/code/python_text_area.h index c58e586c1..6c4765910 100644 --- a/apps/code/python_text_area.h +++ b/apps/code/python_text_area.h @@ -19,6 +19,7 @@ public: bool handleEvent(Ion::Events::Event event) override; bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) override; const char * textToAutocomplete(int * length = nullptr) const; + bool isAutocompleting() const { return m_contentView.isAutocompleting(); } protected: class ContentView : public TextArea::ContentView { public: