1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-03-06 09:32:50 +01:00

Merge pull request from vedran/master

Support end-of-line multi line percent match in visual mode
This commit is contained in:
Alex Plate 2019-02-14 13:14:56 +03:00 committed by GitHub
commit 7bccc2fbdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions
src/com/maddyhome/idea/vim/helper
test/org/jetbrains/plugins/ideavim/action

View File

@ -239,6 +239,13 @@ public class SearchHelper {
int line = caret.getLogicalPosition().line;
int end = EditorHelper.getLineEndOffset(editor, line, true);
// To handle the case where visual mode allows the user to go past the end of the line,
// which will prevent loc from finding a pairable character below
if(pos > 0 && pos == end) {
pos = end - 1;
}
CharSequence chars = editor.getDocument().getCharsSequence();
int loc = -1;
// Search the remainder of the current line for one of the candidate characters

View File

@ -791,6 +791,22 @@ public class MotionActionTest extends VimTestCase {
assertOffset(3);
}
// |%|
public void testPercentVisualModeMatchMultiLineEndOfLine() {
typeTextInFile(parseKeys("v$%"),
"foo(\n" +
")");
assertOffset(5);
}
// |%|
public void testPercentVisualModeMatchFromStartMultiLineEndOfLine() {
typeTextInFile(parseKeys("v$%"),
"(\n" +
")");
assertOffset(2);
}
// |%|
public void testPercentMatchParensInString() {
typeTextInFile(parseKeys("%"),