mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-10 06:40:37 +02:00
Mark should not be deleted due to change commands that start from the beginning of the mark line
This commit is contained in:
parent
4428340fd9
commit
0d6526ea31
src/com/maddyhome/idea/vim/group
test/org/jetbrains/plugins/ideavim/action
@ -33,6 +33,8 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.maddyhome.idea.vim.EventFacade;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.common.Jump;
|
||||
import com.maddyhome.idea.vim.common.Mark;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
@ -552,8 +554,13 @@ public class MarkGroup {
|
||||
else if (delStart.line <= mark.getLogicalLine() && delEnd.line >= mark.getLogicalLine()) {
|
||||
int markLineStartOff = EditorHelper.getLineStartOffset(editor, mark.getLogicalLine());
|
||||
int markLineEndOff = EditorHelper.getLineEndOffset(editor, mark.getLogicalLine(), true);
|
||||
// If the marked line is completely within the deleted text, remove the mark
|
||||
if (delStartOff <= markLineStartOff && delEndOff >= markLineEndOff) {
|
||||
|
||||
Command command = CommandState.getInstance(editor).getCommand();
|
||||
// If text is being changed from the start of the mark line (a special case for mark deletion)
|
||||
boolean changeFromMarkLineStart = command != null && command.getType() == Command.Type.CHANGE
|
||||
&& delStartOff == markLineStartOff;
|
||||
// If the marked line is completely within the deleted text, remove the mark (except the special case)
|
||||
if (delStartOff <= markLineStartOff && delEndOff >= markLineEndOff && !changeFromMarkLineStart) {
|
||||
VimPlugin.getMark().removeMark(ch, mark);
|
||||
logger.debug("Removed mark");
|
||||
}
|
||||
|
@ -50,6 +50,15 @@ public class MarkTest extends VimTestCase {
|
||||
assertNotNull(mark);
|
||||
}
|
||||
|
||||
// |m|
|
||||
public void testMarkIsNotDeletedWhenLineIsChanged() {
|
||||
typeTextInFile(parseKeys("ma", "cc"), " foo\n" +
|
||||
" ba<caret>r\n" +
|
||||
" baz\n");
|
||||
Mark mark = VimPlugin.getMark().getMark(myFixture.getEditor(), 'a');
|
||||
assertNotNull(mark);
|
||||
}
|
||||
|
||||
// |m|
|
||||
public void testMarkIsMovedUpWhenLinesArePartiallyDeletedAbove() {
|
||||
typeTextInFile(parseKeys("mx", "2k", "dd", "0dw"), " foo\n" +
|
||||
|
Loading…
Reference in New Issue
Block a user