mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
[apps/code] Insert only the completing text when autocompleting
This commit is contained in:
@@ -90,6 +90,11 @@ void VariableBoxController::loadFunctionsAndVariables(int scriptIndex, const cha
|
||||
m_builtinNodesCount = 0;
|
||||
m_importedNodesCount = 0;
|
||||
|
||||
if (textToAutocomplete != nullptr && textToAutocompleteLength < 0) {
|
||||
textToAutocompleteLength = strlen(textToAutocomplete);
|
||||
}
|
||||
m_shortenResultBytesCount = textToAutocomplete == nullptr ? 0 : textToAutocompleteLength;
|
||||
|
||||
// Add buitin nodes
|
||||
static const struct { const char * name; ScriptNode::Type type; } builtinNames[] = {
|
||||
{qstr_str(MP_QSTR_abs), ScriptNode::Type::Function},
|
||||
@@ -239,10 +244,6 @@ void VariableBoxController::loadFunctionsAndVariables(int scriptIndex, const cha
|
||||
// Keep track of DEF tokens to differentiate between variables and functions
|
||||
bool defToken = false;
|
||||
|
||||
if (textToAutocomplete != nullptr && textToAutocompleteLength < 0) {
|
||||
textToAutocompleteLength = strlen(textToAutocomplete);
|
||||
}
|
||||
|
||||
while (lex->tok_kind != MP_TOKEN_END) {
|
||||
// Keep only MP_TOKEN_NAME tokens
|
||||
if (lex->tok_kind == MP_TOKEN_NAME) {
|
||||
@@ -435,7 +436,7 @@ bool VariableBoxController::selectLeaf(int rowIndex) {
|
||||
assert(m_importedNodesCount <= k_maxScriptNodesCount);
|
||||
m_selectableTableView.deselectTable();
|
||||
ScriptNode * selectedScriptNode = scriptNodeAtIndex(rowIndex);
|
||||
insertTextInCaller(selectedScriptNode->name(), selectedScriptNode->nameLength());
|
||||
insertTextInCaller(selectedScriptNode->name() + m_shortenResultBytesCount, selectedScriptNode->nameLength() - m_shortenResultBytesCount);
|
||||
if (selectedScriptNode->type() == ScriptNode::Type::Function) {
|
||||
insertTextInCaller(ScriptNodeCell::k_parenthesesWithEmpty);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user