(search) Remove stray spaces in bang commands
This commit is contained in:
parent
06997ff255
commit
ef261cbbd7
@ -53,14 +53,13 @@ public class BangCommand implements SearchCommandInterface {
|
|||||||
if (!bm.isRelativeSpaceOrInvalid(bangKey.length()))
|
if (!bm.isRelativeSpaceOrInvalid(bangKey.length()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
StringBuilder ret = new StringBuilder(bm.prefix().trim());
|
String prefix = bm.prefix().trim();
|
||||||
|
String suffix = bm.suffix(bangKey.length()).trim();
|
||||||
|
|
||||||
if (!ret.isEmpty())
|
String ret = STR."\{prefix} \{suffix}".trim();
|
||||||
ret.append(" ");
|
|
||||||
|
|
||||||
ret.append(bm.suffix(bangKey.length()).trim());
|
return Optional.of(ret)
|
||||||
|
.filter(s -> !s.isBlank());
|
||||||
return Optional.of(ret.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@ -34,4 +34,20 @@ class BangCommandTest {
|
|||||||
assertEquals(match.get(), "test");
|
assertEquals(match.get(), "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchPattern2() {
|
||||||
|
var match = bangCommand.matchBangPattern("test !g", "!g");
|
||||||
|
|
||||||
|
assertTrue(match.isPresent());
|
||||||
|
assertEquals(match.get(), "test");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchPattern3() {
|
||||||
|
var match = bangCommand.matchBangPattern("hello !g world", "!g");
|
||||||
|
|
||||||
|
assertTrue(match.isPresent());
|
||||||
|
assertEquals(match.get(), "hello world");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user