preserve caret position on mode switch

This commit is contained in:
Egor.Ushakov
2017-09-11 16:08:02 +03:00
parent dfc5a7fbfa
commit 5559d6d412
2 changed files with 5 additions and 1 deletions
@@ -275,10 +275,14 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
myMode = mode;
Editor oldEditor = (myInputComponent != null) ? myInputComponent.getInputEditor().getEditor() : null;
myInputComponent = createInputComponent(mode, text);
myMainPanel.removeAll();
myInputComponent.addComponent(myMainPanel, myResultPanel);
XDebuggerEditorBase.copyCaretPosition(oldEditor, myInputComponent.getInputEditor().getEditor());
mySwitchModeAction.putValue(Action.NAME, getSwitchButtonText(mode));
getInputEditor().requestFocusInEditor();
}
@@ -531,7 +531,7 @@ public abstract class XDebuggerEditorBase implements Expandable {
DebuggerUIUtil.getActionShortcutText(IdeActions.ACTION_PREVIOUS_OCCURENCE));
}
private static void copyCaretPosition(@Nullable Editor source, @Nullable Editor destination) {
public static void copyCaretPosition(@Nullable Editor source, @Nullable Editor destination) {
if (source != null && destination != null) {
destination.getCaretModel().moveToOffset(source.getCaretModel().getOffset());
}