Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 28, 2010, 1:25:04 AM (14 years ago)
Author:
landauf
Message:
  • fixed error if a command doesn't exist not being shown while using auto-completion
  • fixed error if a command doesn't exist not being redirected to sub-command auto-completion
  • fixed unneeded line-breaks in auto-completion list
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc

    r7234 r7235  
    6969            }
    7070
    71             ArgumentCompletionList _groupsandcommands(bool bOnlyShowHidden)
     71            ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden)
    7272            {
    7373                ArgumentCompletionList groupList;
     74                std::string fragmentLC = getLowercase(fragment);
    7475
    7576                const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& commands = _ConsoleCommand::getCommands();
    7677                for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
    77                     if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "")
     78                    if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find_first_of(fragmentLC) == 0))
    7879                        groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
    7980
     
    8182                if (it_group != commands.end())
    8283                {
    83                     groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
     84                    if (!groupList.empty())
     85                        groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
    8486
    8587                    for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
    86                         if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
     88                        if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find_first_of(fragmentLC) == 0))
    8789                            groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
    8890                }
     91
     92                if (!groupList.empty() && groupList.back().getDisplay() == "\n")
     93                    groupList.pop_back();
    8994
    9095                return groupList;
     
    113118        }
    114119
    115         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)()
    116         {
    117             return detail::_groupsandcommands(false);
     120        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)(const std::string& fragment)
     121        {
     122            return detail::_groupsandcommands(fragment, false);
    118123        }
    119124
     
    128133            const std::string& hint = evaluation.hint();
    129134
    130             if (evaluation.getPossibleArguments().size() > 0)
     135            if (evaluation.getPossibleArguments().size() > 0 && evaluation.getPossibleArgumentsSize() > 0)
    131136            {
    132137                return evaluation.getPossibleArguments();
     
    145150
    146151            if (tokens.size() == 0)
    147                 return detail::_groupsandcommands(true);
     152                return detail::_groupsandcommands(fragment, true);
    148153
    149154            if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
     
    156161                    return detail::_subcommands(fragment, tokens[0], true);
    157162                else
    158                     return detail::_groupsandcommands(true);
     163                    return detail::_groupsandcommands(fragment, true);
    159164            }
    160165
Note: See TracChangeset for help on using the changeset viewer.