mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Potenially fix quoted string completion
This commit is contained in:
@ -431,7 +431,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
|
||||
private Stream<Substring> parseArgs(String input) {
|
||||
return new CommandArgParser(CommandArgParser.spaceSplit(input.substring(1))).parseArgs();
|
||||
return CommandArgParser.forArgString(input.substring(1)).parseArgs();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -31,6 +31,10 @@ import java.util.stream.Stream;
|
||||
|
||||
public class CommandArgParser {
|
||||
|
||||
public static CommandArgParser forArgString(String argString) {
|
||||
return new CommandArgParser(spaceSplit(argString));
|
||||
}
|
||||
|
||||
public static ImmutableList<Substring> spaceSplit(String string) {
|
||||
ImmutableList.Builder<Substring> result = ImmutableList.builder();
|
||||
int index = 0;
|
||||
@ -79,14 +83,14 @@ public class CommandArgParser {
|
||||
if (strPart.endsWith("\"") && strPart.length() > 1) {
|
||||
currentArg.add(Substring.wrap(
|
||||
strPart.substring(1, strPart.length() - 1),
|
||||
part.getStart(), part.getEnd()
|
||||
part.getStart() + 1, part.getEnd() - 1
|
||||
));
|
||||
finishArg();
|
||||
} else {
|
||||
state = State.QUOTE;
|
||||
currentArg.add(Substring.wrap(
|
||||
strPart.substring(1),
|
||||
part.getStart(), part.getEnd()
|
||||
part.getStart() + 1, part.getEnd()
|
||||
));
|
||||
}
|
||||
} else {
|
||||
@ -100,7 +104,7 @@ public class CommandArgParser {
|
||||
state = State.NORMAL;
|
||||
currentArg.add(Substring.wrap(
|
||||
part.getSubstring().substring(0, part.getSubstring().length() - 1),
|
||||
part.getStart(), part.getEnd()
|
||||
part.getStart(), part.getEnd() - 1
|
||||
));
|
||||
finishArg();
|
||||
} else {
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.internal.util.Substring;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
@ -65,7 +66,9 @@ public class CommandUtil {
|
||||
* Fix {@code suggestions} to replace the last space-separated word in {@code arguments}.
|
||||
*/
|
||||
public static List<String> fixSuggestions(String arguments, List<Substring> suggestions) {
|
||||
Substring lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments));
|
||||
Substring lastArg = Iterables.getLast(
|
||||
CommandArgParser.spaceSplit(arguments)
|
||||
);
|
||||
return suggestions.stream()
|
||||
.map(suggestion -> CommandUtil.suggestLast(lastArg, suggestion))
|
||||
.filter(Optional::isPresent)
|
||||
|
Reference in New Issue
Block a user