Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Fix bug with spaces at end of suggestions.
Dieser Commit ist enthalten in:
Ursprung
0e25839490
Commit
f83de2a703
@ -70,14 +70,18 @@ public class CommandUtil {
|
|||||||
);
|
);
|
||||||
return suggestions.stream()
|
return suggestions.stream()
|
||||||
// Re-map suggestions to only operate on the last non-quoted word
|
// Re-map suggestions to only operate on the last non-quoted word
|
||||||
.map(CommandUtil::onlyOnLastQuotedWord)
|
.map(suggestion -> onlyOnLastQuotedWord(lastArg, suggestion))
|
||||||
.map(suggestion -> CommandUtil.suggestLast(lastArg, suggestion))
|
.map(suggestion -> suggestLast(lastArg, suggestion))
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Substring onlyOnLastQuotedWord(Substring suggestion) {
|
private static Substring onlyOnLastQuotedWord(Substring lastArg, Substring suggestion) {
|
||||||
|
if (suggestion.getSubstring().startsWith(lastArg.getSubstring())) {
|
||||||
|
// This is already fine.
|
||||||
|
return suggestion;
|
||||||
|
}
|
||||||
String substr = suggestion.getSubstring();
|
String substr = suggestion.getSubstring();
|
||||||
int sp = substr.lastIndexOf(' ');
|
int sp = substr.lastIndexOf(' ');
|
||||||
if (sp < 0) {
|
if (sp < 0) {
|
||||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.internal.util;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An explicit substring. Provides the range from which it was taken.
|
* An explicit substring. Provides the range from which it was taken.
|
||||||
*/
|
*/
|
||||||
@ -31,7 +33,7 @@ public final class Substring {
|
|||||||
* a Substring.
|
* a Substring.
|
||||||
*/
|
*/
|
||||||
public static Substring from(String original, int start) {
|
public static Substring from(String original, int start) {
|
||||||
return wrap(original.substring(start), start, original.length());
|
return new Substring(original.substring(start), start, original.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,13 +41,15 @@ public final class Substring {
|
|||||||
* a Substring.
|
* a Substring.
|
||||||
*/
|
*/
|
||||||
public static Substring from(String original, int start, int end) {
|
public static Substring from(String original, int start, int end) {
|
||||||
return wrap(original.substring(start, end), start, end);
|
return new Substring(original.substring(start, end), start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the given parameters into a Substring instance.
|
* Wrap the given parameters into a Substring instance.
|
||||||
*/
|
*/
|
||||||
public static Substring wrap(String substring, int start, int end) {
|
public static Substring wrap(String substring, int start, int end) {
|
||||||
|
checkArgument(0 <= start, "Start must be greater than or equal to zero");
|
||||||
|
checkArgument(start <= end, "End must be greater than or equal to start");
|
||||||
return new Substring(substring, start, end);
|
return new Substring(substring, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren