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

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


The following commit(s) were added to refs/heads/master by this push:
     new a44b5b2  [NETBEANS-4444] The selected text is not removed in the Find 
Combobox when text is input via IME
     new b8441cf  Merge pull request #2188 from 
junichi11/netbeans-4444-editor-search
a44b5b2 is described below

commit a44b5b225f4cf1fc72a5a82416e58a0b7cde3fa9
Author: Junichi Yamamoto <[email protected]>
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.
---
 .../modules/editor/search/SearchComboBoxEditor.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to