IDEA-100797 Cut/DeleteLine no longer moves the caret to column 1 after cutting line (when there is no selection)

Reset caret to the first column on line cut (keep column on 'Line Delete' action)
This commit is contained in:
Denis.Zhdanov
2013-02-13 15:01:47 +04:00
parent d0b3a0a752
commit ce48ad5f63
@@ -57,10 +57,8 @@ public class CutHandler extends EditorWriteActionHandler {
return;
}
VisualPosition positionToRestore = null;
SelectionModel selectionModel = editor.getSelectionModel();
if (!selectionModel.hasSelection() && !selectionModel.hasBlockSelection()) {
positionToRestore = editor.getCaretModel().getVisualPosition();
selectionModel.selectLineAtCaret();
if (!selectionModel.hasSelection()) return;
}
@@ -71,16 +69,12 @@ public class CutHandler extends EditorWriteActionHandler {
EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_COPY).execute(editor, dataContext);
if (start != end) {
// There is a possible case that 'sticky selection' is active. It's automatically removed on copying then, so, we explictly
// There is a possible case that 'sticky selection' is active. It's automatically removed on copying then, so, we explicitly
// remove the text.
editor.getDocument().deleteString(start, end);
}
else {
EditorModificationUtil.deleteSelectedText(editor);
}
if (positionToRestore != null) {
editor.getCaretModel().moveToVisualPosition(positionToRestore);
}
}
}