Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIM-2114 Do not override registers when deleting empty range #250

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}