Search in sources :

Example 6 with Mark

use of com.maddyhome.idea.vim.common.Mark in project ideavim by JetBrains.

the class MotionGroup method moveCaretToMark.

public int moveCaretToMark(@NotNull final Editor editor, char ch) {
    final Mark mark = VimPlugin.getMark().getMark(editor, ch);
    if (mark != null) {
        final VirtualFile vf = EditorData.getVirtualFile(editor);
        if (vf == null) {
            return -1;
        }
        final LogicalPosition lp = new LogicalPosition(mark.getLogicalLine(), mark.getCol());
        if (!vf.getPath().equals(mark.getFilename())) {
            final Editor selectedEditor = selectEditor(editor, vf);
            if (selectedEditor != null) {
                moveCaret(selectedEditor, selectedEditor.logicalPositionToOffset(lp));
            }
            return -2;
        } else {
            return editor.logicalPositionToOffset(lp);
        }
    } else {
        return -1;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Mark(com.maddyhome.idea.vim.common.Mark) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 7 with Mark

use of com.maddyhome.idea.vim.common.Mark in project ideavim by JetBrains.

the class MotionGroup method moveCaretToMarkLine.

public int moveCaretToMarkLine(@NotNull final Editor editor, char ch) {
    final Mark mark = VimPlugin.getMark().getMark(editor, ch);
    if (mark != null) {
        final VirtualFile vf = EditorData.getVirtualFile(editor);
        if (vf == null) {
            return -1;
        }
        final int line = mark.getLogicalLine();
        if (!vf.getPath().equals(mark.getFilename())) {
            final Editor selectedEditor = selectEditor(editor, vf);
            if (selectedEditor != null) {
                moveCaret(selectedEditor, moveCaretToLineStartSkipLeading(selectedEditor, line));
            }
            return -2;
        } else {
            return moveCaretToLineStartSkipLeading(editor, line);
        }
    } else {
        return -1;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Mark(com.maddyhome.idea.vim.common.Mark) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 8 with Mark

use of com.maddyhome.idea.vim.common.Mark in project ideavim by JetBrains.

the class MarkTest method testMarkIsMovedDownWhenLinesAreInsertedAboveWithIndentation.

// |m|
public void testMarkIsMovedDownWhenLinesAreInsertedAboveWithIndentation() {
    typeTextInFile(parseKeys("mY", "Obiff"), "    foo\n" + "    ba<caret>r\n" + "    baz\n");
    Mark mark = VimPlugin.getMark().getMark(myFixture.getEditor(), 'Y');
    assertNotNull(mark);
    assertEquals(2, mark.getLogicalLine());
    assertEquals(6, mark.getCol());
}
Also used : Mark(com.maddyhome.idea.vim.common.Mark)

Example 9 with Mark

use of com.maddyhome.idea.vim.common.Mark in project ideavim by JetBrains.

the class MarkTest method testMarkIsMovedUpWhenLinesAreDeletedAbove.

// |m|
public void testMarkIsMovedUpWhenLinesAreDeletedAbove() {
    typeTextInFile(parseKeys("mx", "2k", "2dd"), "    foo\n" + "    bar\n" + "    ba<caret>z\n");
    Mark mark = VimPlugin.getMark().getMark(myFixture.getEditor(), 'x');
    assertNotNull(mark);
    assertEquals(0, mark.getLogicalLine());
    assertEquals(6, mark.getCol());
}
Also used : Mark(com.maddyhome.idea.vim.common.Mark)

Example 10 with Mark

use of com.maddyhome.idea.vim.common.Mark in project ideavim by JetBrains.

the class MarkTest method testMarkIsMovedDownWhenLinesAreInsertedAbove.

// |m|
public void testMarkIsMovedDownWhenLinesAreInsertedAbove() {
    typeTextInFile(parseKeys("mY", "Obiff"), "foo\n" + "ba<caret>r\n" + "baz\n");
    Mark mark = VimPlugin.getMark().getMark(myFixture.getEditor(), 'Y');
    assertNotNull(mark);
    assertEquals(2, mark.getLogicalLine());
    assertEquals(2, mark.getCol());
}
Also used : Mark(com.maddyhome.idea.vim.common.Mark)

Aggregations

Mark (com.maddyhome.idea.vim.common.Mark)21 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)4 Nullable (org.jetbrains.annotations.Nullable)4 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Jump (com.maddyhome.idea.vim.common.Jump)2 Element (org.jdom.Element)2 Command (com.maddyhome.idea.vim.command.Command)1 TextRange (com.maddyhome.idea.vim.common.TextRange)1