1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-03-01 04:46:02 +01:00

Fix search with offset

This commit is contained in:
Alex Plate 2022-10-28 09:01:48 +03:00
parent 860592291f
commit ac69c0d9c6
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 18 additions and 5 deletions
src
main/java/com/maddyhome/idea/vim/group
test/java/org/jetbrains/plugins/ideavim/group

View File

@ -288,15 +288,20 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
if (logger.isDebugEnabled()) logger.debug("pattern=" + pattern);
if (p.charAt() != type) {
logger.debug("no offset");
patternOffset = "";
}
else {
if (p.charAt() == type) {
p.inc();
patternOffset = p.toString();
if (logger.isDebugEnabled()) logger.debug("offset=" + patternOffset);
}
if (end.charAt(0) == type) {
end.inc();
patternOffset = end.toString();
if (logger.isDebugEnabled()) logger.debug("Pattern contains offset " + patternOffset);
}
else {
logger.debug("no offset");
patternOffset = "";
}
}
else if (command.length() == 1) {
patternOffset = "";

View File

@ -194,6 +194,14 @@ class SearchGroupTest : VimTestCase() {
assertOffset(6)
}
fun `test search e-1 motion offset`() {
doTest(
"/two/e-1<Enter>",
"${c}one two three",
"one t${c}wo three",
)
}
// |/pattern/e|
fun `test search e+2 motion offset`() {
typeTextInFile(