From c2c8a2011816a2d4e9deb92539838df92b339df2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 17 Aug 2018 16:46:54 +0300 Subject: [PATCH] [ui] better caret behavior in the exception dialog - no more caret jumping on background events - default position is at the end of a comment --- .../intellij/diagnostic/IdeErrorsDialog.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java index 43569f5033b3..0e9f9e133d3d 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java @@ -79,7 +79,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene private final boolean myInternalMode; private final Set myAcceptedNotices; private final List myMessageClusters = new ArrayList<>(); // exceptions with the same stacktrace - private int myIndex; + private int myIndex, myLastIndex = -1; private JLabel myCountLabel; private HyperlinkLabel.Croppable myInfoLabel; @@ -510,16 +510,20 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene AbstractMessage message = cluster.first; boolean canReport = cluster.canSubmit(); - myCommentArea.setText(message.getAdditionalInfo()); - myCommentArea.setCaretPosition(0); - myCommentArea.setEditable(canReport); + if (myLastIndex != myIndex) { + myCommentArea.setText(message.getAdditionalInfo()); - myAttachmentsList.clear(); - myAttachmentsList.addItem(STACKTRACE_ATTACHMENT, true); - for (Attachment attachment : message.getAllAttachments()) { - myAttachmentsList.addItem(attachment.getName(), attachment.isIncluded()); + myAttachmentsList.clear(); + myAttachmentsList.addItem(STACKTRACE_ATTACHMENT, true); + for (Attachment attachment : message.getAllAttachments()) { + myAttachmentsList.addItem(attachment.getName(), attachment.isIncluded()); + } + myAttachmentsList.setSelectedIndex(0); + + myLastIndex = myIndex; } - myAttachmentsList.setSelectedIndex(0); + + myCommentArea.setEditable(canReport); myAttachmentsList.setEditable(canReport); } @@ -660,7 +664,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene @Override public void actionPerformed(@NotNull AnActionEvent e) { - myIndex--; + myLastIndex = myIndex--; updateControls(); } } @@ -681,7 +685,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene @Override public void actionPerformed(@NotNull AnActionEvent e) { - myIndex++; + myLastIndex = myIndex++; updateControls(); } }