prevent displaying auto completes for no filter argument or only "_"

This commit is contained in:
thrust26 2017-10-11 11:38:38 +02:00
parent c93d7e265d
commit 5883f2dfcc
2 changed files with 25 additions and 15 deletions

View File

@ -704,16 +704,20 @@ string Debugger::builtinHelp() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::getCompletions(const char* in, StringList& list) const
{
for(const auto& iter: myFunctions)
// skip if filter equals "_" only
if(!BSPF::equalsIgnoreCase(in, "_"))
{
const char* l = iter.first.c_str();
if(BSPF::matches(l, in))
list.push_back(l);
}
for(const auto& iter : myFunctions)
{
const char* l = iter.first.c_str();
if(BSPF::matches(l, in))
list.push_back(l);
}
for(int i = 0; pseudo_registers[i][0] != 0; ++i)
if(BSPF::matches(pseudo_registers[i][0], in))
list.push_back(pseudo_registers[i][0]);
for(int i = 0; pseudo_registers[i][0] != 0; ++i)
if(BSPF::matches(pseudo_registers[i][0], in))
list.push_back(pseudo_registers[i][0]);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -220,6 +220,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
}
}
str[len] = '\0';
int strLen = len - lastDelimPos - 1;
StringList list;
string completionList;
@ -227,7 +228,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
if(lastDelimPos < 0)
{
// no delimiters, do command completion:
// no delimiters, do only command completion:
const DebuggerParser& parser = instance().debugger().parser();
parser.getCompletions(str, list);
@ -249,11 +250,15 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
}
else
{
// we got a delimiter, so this must be a label or a function
const Debugger& dbg = instance().debugger();
// do not show ALL labels without any filter as it makes no sense
if(strLen > 0)
{
// we got a delimiter, so this must be a label or a function
const Debugger& dbg = instance().debugger();
dbg.cartDebug().getCompletions(str + lastDelimPos + 1, list);
dbg.getCompletions(str + lastDelimPos + 1, list);
dbg.cartDebug().getCompletions(str + lastDelimPos + 1, list);
dbg.getCompletions(str + lastDelimPos + 1, list);
}
}
if(list.size() < 1)
@ -266,6 +271,8 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
prefix = getCompletionPrefix(list);
}
// TODO: tab through list
if(list.size() == 1)
{
// add to buffer as though user typed it (plus a space)
@ -927,8 +934,7 @@ string PromptWidget::getCompletionPrefix(const StringList& completions)
for(uInt32 j = i + 1; j < completions.size(); j++)
{
string s2 = completions[j];
if(!BSPF::startsWithIgnoreCase(s2, find))
if(!BSPF::startsWithIgnoreCase(completions[j], find))
return s1.substr(0, len - 1);
}
}