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

@ -703,6 +703,9 @@ string Debugger::builtinHelp() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::getCompletions(const char* in, StringList& list) const
{
// skip if filter equals "_" only
if(!BSPF::equalsIgnoreCase(in, "_"))
{
for(const auto& iter : myFunctions)
{
@ -715,6 +718,7 @@ void Debugger::getCompletions(const char* in, StringList& list) const
if(BSPF::matches(pseudo_registers[i][0], in))
list.push_back(pseudo_registers[i][0]);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::lockBankswitchState()

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);
@ -248,6 +249,9 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
instance().debugger().parser().getCompletions(str + lastDelimPos + 1, list);
}
else
{
// 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();
@ -255,6 +259,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
dbg.cartDebug().getCompletions(str + lastDelimPos + 1, list);
dbg.getCompletions(str + lastDelimPos + 1, list);
}
}
if(list.size() < 1)
break;
@ -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);
}
}