Skip to content

Commit

Permalink
[NETBEANS-4444] The selected text is not removed in the Find Combobox…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
junichi11 authored and lkishalmi committed Jan 11, 2021
1 parent 2601979 commit 90d1c35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ide/editor.search/nbproject/project.properties
Expand Up @@ -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
Expand Up @@ -123,6 +123,25 @@ public void propertyChange(PropertyChangeEvent evt) {
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
}
}
}
}
}
}
});
}
Expand Down

0 comments on commit 90d1c35

Please sign in to comment.