From e73ae9bcdf3853c119db51ea27aacfc27f33eed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 22 Apr 2020 15:51:34 +0200 Subject: [PATCH] [apps/code] Fix varbox that should autocomplete the current word --- apps/code/python_text_area.cpp | 3 +++ apps/code/python_text_area.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/apps/code/python_text_area.cpp b/apps/code/python_text_area.cpp index e1fe0a923..f0ed0ff99 100644 --- a/apps/code/python_text_area.cpp +++ b/apps/code/python_text_area.cpp @@ -54,6 +54,9 @@ static inline size_t TokenLength(mp_lexer_t * lex, const char * tokenPosition) { return lex->column - lex->tok_column; } bool PythonTextArea::shouldAutocomplete(const char * autocompletionLocation) const { + if (isAutocompleting()) { + return true; + } const char * location = autocompletionLocation != nullptr ? autocompletionLocation : cursorLocation(); CodePoint prevCodePoint = UTF8Helper::PreviousCodePoint(m_contentView.editedText(), location); return !UTF8Helper::CodePointIsEndOfWord(prevCodePoint) diff --git a/apps/code/python_text_area.h b/apps/code/python_text_area.h index 755f791c1..1bbcd2531 100644 --- a/apps/code/python_text_area.h +++ b/apps/code/python_text_area.h @@ -18,6 +18,9 @@ public: void unloadSyntaxHighlighter() { m_contentView.unloadSyntaxHighlighter(); } bool handleEvent(Ion::Events::Event event) override; bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) override; + /* shouldAutocomplete returns true if there is currently autocompletion, or if + * there should be autocompletion but there is not because there is no word to + * autocomplete. */ bool shouldAutocomplete(const char * autocompletionLocation = nullptr) const; bool isAutocompleting() const { return m_contentView.isAutocompleting(); } protected: