From 2806b9890bd3078b2a27d4d6ce2e9d1f0d1eb8ac Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Wed, 14 Jan 2015 16:29:01 +0300 Subject: [PATCH] IDEA-135089 Search and replace multiline text allows to input only three lines --- .../intellij/find/EditorSearchComponent.java | 17 ++++++++++++++--- .../util/src/com/intellij/util/ui/UIUtil.java | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java b/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java index 747cea82df93..f30da0b39b4b 100644 --- a/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java +++ b/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java @@ -450,6 +450,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data else { nothingToSearchFor(); } + if (mySearchField instanceof JTextArea) { + UIUtil.adjustRows((JTextArea)mySearchField, 2, 6); + } } public boolean isRegexp() { @@ -637,6 +640,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data private void replaceFieldDocumentChanged() { setMatchesLimit(LivePreviewController.MATCHES_LIMIT); myFindModel.setStringToReplace(myReplaceField.getText()); + if (myReplaceField instanceof JTextArea) { + UIUtil.adjustRows((JTextArea)myReplaceField, 2, 6); + } } private boolean canReplaceCurrent() { @@ -697,12 +703,17 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data super.paintBorder(g); paintBorderOfTextField(g); } + + @Override + public Dimension getPreferredSize() { + return super.getPreferredSize(); + } }; ((JTextArea)editorTextField).setColumns(25); - ((JTextArea)editorTextField).setRows(3); + ((JTextArea)editorTextField).setRows(2); final JScrollPane scrollPane = new JBScrollPane(editorTextField, - ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); myLeftComponent.add(scrollPane, constraint); componentRef.set(scrollPane); } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 02bed0eedf02..6af544af7755 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -3215,6 +3215,10 @@ public class UIUtil { textComponent.getActionMap().put("redoKeystroke", REDO_ACTION); } + public static void adjustRows(JTextArea area, int minRows, int maxRows) { + area.setRows(Math.max(minRows, Math.min(maxRows, area.getText().split("\n").length))); + } + public static void playSoundFromResource(final String resourceName) { final Class callerClass = ReflectionUtil.getGrandCallerClass(); if (callerClass == null) return;