public static @Nullable String trimBeforeLastSpace(final String suggestion, final CommandInput commandInput) {
        // get the input similarly to FilteringCommandSuggestionProcessor
        final String input;
        if (commandInput.isEmpty(true /* ignoreWhitespace */)) {
            input = "";
        } else {
            input = commandInput.copy().skipWhitespace().remainingInput();
        }
        return trimBeforeLastSpace(suggestion, input);
    }
Trims before the last space from suggestion, if it matches input tokens.

@param suggestion   suggestion
@param commandInput command input
@return filtered suggestion text
cloud-core/src/main/java/org/incendo/cloud/util/StringUtils.java