mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user