void (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor); if (templateState != null && !templateState.isFinished()) { final TextRange range = templateState.getCurrentVariableRange(); final int caretOffset = editor.getCaretModel().getOffset(); if (range != null && shouldStayInsideVariable(range, caretOffset)) { int selectionOffset = editor.getSelectionModel().getLeadSelectionOffset(); int offsetToMove = myIsHomeHandler ? range.getStartOffset() : range.getEndOffset(); editor.getCaretModel().moveToOffset(offsetToMove); EditorModificationUtil.scrollToCaret(editor); if (myWithSelection) { editor.getSelectionModel().setSelection(selectionOffset, offsetToMove); } else { editor.getSelectionModel().removeSelection(); } return; } } myOriginalHandler.execute(editor, caret, dataContext); }