[apps/code] Fix varbox that should autocomplete the current word

This commit is contained in:
Léa Saviot
2020-04-22 15:51:34 +02:00
committed by Émilie Feral
parent dd6c2a4f54
commit e73ae9bcdf
2 changed files with 6 additions and 0 deletions

View File

@@ -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)

View File

@@ -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: