Skip to content

Commit

Permalink
VIM-2114 Do not override registers when deleting empty range
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalus authored and AlexPl292 committed Nov 13, 2020
1 parent 7d6a643 commit 75a1bb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/com/maddyhome/idea/vim/group/RegisterGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ public boolean storeTextInternal(@NotNull Editor editor, @NotNull TextRange rang

int start = range.getStartOffset();
int end = range.getEndOffset();

if (isDelete && start == end) {
return true;
}

// Normalize the start and end
if (start > end) {
int t = start;
Expand Down
12 changes: 12 additions & 0 deletions test/org/jetbrains/plugins/ideavim/action/CopyActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,16 @@ public void testPutInEmptyFile() {
typeTextInFile(parseKeys("\"ap"), "");
myFixture.checkResult("test");
}

public void testOverridingRegisterWithEmptyTag() {
configureByText("<root>\n" +
"<a><caret>value</a>\n" +
"<b></b>\n" +
"</root>\n");
typeText(parseKeys("dit", "j", "cit", "<C-R>\""));
myFixture.checkResult("<root>\n" +
"<a></a>\n" +
"<b>value</b>\n" +
"</root>\n");
}
}

0 comments on commit 75a1bb7

Please sign in to comment.