public void execute(jetbrains.mps.openapi.editor.EditorContext context) { EditorCell selectedCell = getDeepestSelectedCell(context); int caretX = selectedCell.getCaretX(); EditorComponent editorComponent = (EditorComponent) context.getEditorComponent(); if (editorComponent.hasLastCaretX()) { caretX = editorComponent.getLastCaretX(); } editorComponent.saveLastCaretX(caretX); EditorCell target = findTarget(selectedCell, caretX); target.setCaretX(caretX); editorComponent.changeSelection(target, false); }
public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) { EditorCell selectedCell = getDeepestSelectedCell(context); return selectedCell != null && findTarget(selectedCell, selectedCell.getCaretX()) != null; }