This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch release120
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/release120 by this push:
     new 90d1c35  [NETBEANS-4444] The selected text is not removed in the Find 
Combobox when text is input via IME
90d1c35 is described below

commit 90d1c35f1b3eb32bfcba92f0b8dad1005abd3f47
Author: Junichi Yamamoto <junich...@apache.org>
AuthorDate: Sun Jun 14 20:47:53 2020 +0900

    [NETBEANS-4444] The selected text is not removed in the Find Combobox when 
text is input via IME
    
    Selection is not removed when text is input via IME. So, just remove it 
when the caret is changed.
---
 ide/editor.search/nbproject/project.properties        |  2 +-
 .../modules/editor/search/SearchComboBoxEditor.java   | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/ide/editor.search/nbproject/project.properties 
b/ide/editor.search/nbproject/project.properties
index 72b4fd1..7af9d80 100644
--- a/ide/editor.search/nbproject/project.properties
+++ b/ide/editor.search/nbproject/project.properties
@@ -16,4 +16,4 @@
 # under the License.
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
-spec.version.base=1.33.0
+spec.version.base=1.33.1
diff --git 
a/ide/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
 
b/ide/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
index b5d8f03..45d303f 100644
--- 
a/ide/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
+++ 
b/ide/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
@@ -123,6 +123,25 @@ public class SearchComboBoxEditor implements 
ComboBoxEditor {
                         DocumentUtilities.addDocumentListener(newDoc, 
manageViewListener, DocumentListenerPriority.AFTER_CARET_UPDATE);
                     }
                 }
+                // NETBEANS-4444
+                // selection is not removed when text is input via IME
+                // so, just remove it when the caret is changed
+                if ("caret".equals(evt.getPropertyName())) { // NOI18N
+                    if (evt.getOldValue() instanceof Caret) {
+                        Caret oldCaret = (Caret) evt.getOldValue();
+                        if (oldCaret != null) {
+                            int dotPosition = oldCaret.getDot();
+                            int markPosition = oldCaret.getMark();
+                            if (dotPosition != markPosition) {
+                                try {
+                                    
editorPane.getDocument().remove(Math.min(markPosition, dotPosition), 
Math.abs(markPosition - dotPosition));
+                                } catch (BadLocationException ex) {
+                                    LOG.log(Level.WARNING, "Invalid removal 
offset: {0}", ex.offsetRequested()); // NOI18N
+                                }
+                            }
+                        }
+                    }
+                }
             }
         });
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to