mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/code] Autocompletion for "abs" proposes parentheses
This commit is contained in:
@@ -375,24 +375,30 @@ bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIn
|
||||
bool addParentheses = false;
|
||||
const char * textToInsert = varBox->autocompletionAlternativeAtIndex(autocompletionLocation - autocompletionTokenBeginning, &textToInsertLength, &addParentheses, nextIndex, currentIndexToUpdate);
|
||||
|
||||
// Try to insert the text (this might fail if the buffer is full)
|
||||
if (textToInsert != nullptr
|
||||
&& textToInsertLength > 0
|
||||
&& m_contentView.insertTextAtLocation(textToInsert, const_cast<char *>(autocompletionLocation), textToInsertLength))
|
||||
{
|
||||
if (textToInsert == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (textToInsertLength > 0) {
|
||||
// Try to insert the text (this might fail if the buffer is full)
|
||||
if (!m_contentView.insertTextAtLocation(textToInsert, const_cast<char *>(autocompletionLocation), textToInsertLength)) {
|
||||
return false;
|
||||
}
|
||||
autocompletionLocation += textToInsertLength;
|
||||
m_contentView.setAutocompletionEnd(autocompletionLocation);
|
||||
// Try to insert the parentheses if needed text
|
||||
const char * parentheses = ScriptNodeCell::k_parentheses;
|
||||
constexpr int parenthesesLength = 2;
|
||||
assert(strlen(parentheses) == parenthesesLength);
|
||||
if (addParentheses && m_contentView.insertTextAtLocation(parentheses, const_cast<char *>(autocompletionLocation), parenthesesLength)) {
|
||||
m_contentView.setAutocompleting(true);
|
||||
m_contentView.setAutocompletionEnd(autocompletionLocation + parenthesesLength);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Try to insert the parentheses if needed
|
||||
const char * parentheses = ScriptNodeCell::k_parentheses;
|
||||
constexpr int parenthesesLength = 2;
|
||||
assert(strlen(parentheses) == parenthesesLength);
|
||||
/* If couldInsertText is false, we should not try to add the parentheses as
|
||||
* there was already not enough space to add the autocompletion. */
|
||||
if (addParentheses && m_contentView.insertTextAtLocation(parentheses, const_cast<char *>(autocompletionLocation), parenthesesLength)) {
|
||||
m_contentView.setAutocompleting(true);
|
||||
m_contentView.setAutocompletionEnd(autocompletionLocation + parenthesesLength);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PythonTextArea::cycleAutocompletion(bool downwards) {
|
||||
|
||||
@@ -522,7 +522,7 @@ void VariableBoxController::loadBuiltinNodes(const char * textToAutocomplete, in
|
||||
bool strictlyStartsWith = false;
|
||||
startsWith = NodeNameCompare(&node, textToAutocomplete, textToAutocompleteLength, &strictlyStartsWith);
|
||||
if (startsWith == 0) { // The node name and name are equal
|
||||
startsWith = builtinNames[i].type == ScriptNode::Type::WithParentheses ? 0 : -1; // We accept the node only if it has parentheses
|
||||
startsWith = node.type() == ScriptNode::Type::WithParentheses ? 0 : -1; // We accept the node only if it has parentheses
|
||||
} else if (strictlyStartsWith) {
|
||||
startsWith = 0;
|
||||
} else if (startsWith > 0) {
|
||||
|
||||
Reference in New Issue
Block a user