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;
}
}
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;
}
}
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());
}
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());
}
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());
}
Aggregations