summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginManager.cpp
diff options
context:
space:
mode:
authorMarvin Kopf <marvinkopf@posteo.de>2016-02-02 15:07:50 +0100
committerMarvin Kopf <marvinkopf@posteo.de>2016-02-02 18:59:50 +0100
commit9840cc821868231cac3023e21ee60fb8ea3cb072 (patch)
tree93c8e31a08f8713342309b35f045f38ece1a80c7 /src/Bindings/PluginManager.cpp
parentMerge pull request #2936 from mathias-github/master (diff)
downloadcuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar.gz
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar.bz2
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar.lz
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar.xz
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.tar.zst
cuberite-9840cc821868231cac3023e21ee60fb8ea3cb072.zip
Diffstat (limited to 'src/Bindings/PluginManager.cpp')
-rw-r--r--src/Bindings/PluginManager.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 4d291f164..bf907b31d 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1894,7 +1894,27 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector &
// Player doesn't have permission for the command
continue;
}
- a_Results.push_back(itr->first);
+
+ /* Client expects to only get back the last part of a space separated command.
+ Find the position of the beginning of the last part:
+ Position of last space + 1 for space separated commands
+ string::npos + 1 = 0 for commands that are not separated
+
+ Then skip all commands that have too many subcommands.
+ When the client asks for suggestions for "/time s"
+ the server must skip all commands that consist of more than 2 words just as
+ "/time set day". Or in other words, the position of the last space (separator)
+ in the strings must be equal or string::npos for both. */
+ size_t LastSpaceInText = a_Text.find_last_of(' ') + 1;
+ size_t LastSpaceInSuggestion = itr->first.find_last_of(' ') + 1;
+
+ if (LastSpaceInText != LastSpaceInSuggestion)
+ {
+ // Suggestion has more subcommands than a_Text
+ continue;
+ }
+
+ a_Results.push_back(itr->first.substr(LastSpaceInSuggestion));
}
}