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

VIM-2113 Increase tag range only in visual mode

This commit is contained in:
Jan Palus 2020-08-31 20:26:59 +02:00 committed by Alex Pláte
parent 3881b905be
commit 2758071d31
2 changed files with 19 additions and 9 deletions
src/com/maddyhome/idea/vim/helper
test/org/jetbrains/plugins/ideavim/action

View File

@ -29,6 +29,7 @@ import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.option.ListOption;
import com.maddyhome.idea.vim.option.OptionsManager;
@ -541,16 +542,19 @@ public class SearchHelper {
selectionEndWithoutNewline++;
}
if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline &&
final CommandState.Mode mode = CommandState.getInstance(editor).getMode();
if (mode == CommandState.Mode.VISUAL) {
if (closingTagTextRange.getStartOffset() == selectionEndWithoutNewline &&
openingTag.getEndOffset() == selectionStart) {
// Special case: if the inner tag is already selected we should like isOuter is active
// Note that we need to ignore newlines, because their selection is lost between multiple "it" invocations
isOuter = true;
}
else if (openingTag.getEndOffset() == closingTagTextRange.getStartOffset() &&
selectionStart == openingTag.getEndOffset()) {
// Special case: for an empty tag pair (e.g. <a></a>) the whole tag is selected if the caret is in the middle.
isOuter = true;
// Special case: if the inner tag is already selected we should like isOuter is active
// Note that we need to ignore newlines, because their selection is lost between multiple "it" invocations
isOuter = true;
}
else if (openingTag.getEndOffset() == closingTagTextRange.getStartOffset() &&
selectionStart == openingTag.getEndOffset()) {
// Special case: for an empty tag pair (e.g. <a></a>) the whole tag is selected if the caret is in the middle.
isOuter = true;
}
}
if (isOuter) {

View File

@ -442,6 +442,12 @@ public class MotionActionTest extends VimTestCase {
myFixture.checkResult("<a></a>");
}
// VIM-2113
public void testReplaceEmptyTagContent() {
typeTextInFile(parseKeys("cit"),"<a><c><caret></c></a>");
myFixture.checkResult("<a><c></c></a>");
}
// |[(|
public void testUnmatchedOpenParenthesis() {
typeTextInFile(parseKeys("[("),