changeset 40:c803a2c89ea0

Make the JScrollPane scroll properly to highlighted text.
author David Barts <n5jrn@me.com>
date Wed, 05 Feb 2020 16:47:25 -0800
parents 2a5808156f99
children 33fbe3a78d84
files src/name/blackcap/clipman/PasteboardQueue.kt
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/name/blackcap/clipman/PasteboardQueue.kt	Fri Jan 31 00:06:59 2020 -0800
+++ b/src/name/blackcap/clipman/PasteboardQueue.kt	Wed Feb 05 16:47:25 2020 -0800
@@ -110,7 +110,10 @@
             pos = search(needle, text, pos)
             if (pos >= 0) {
                 si.highlighter.addHighlight(pos, pos+needle.length, painter)
-                si.scrollRectToVisible(si.getBounds(null))
+                val r = si.modelToView(pos).apply {
+                    add(si.modelToView(pos + needle.length - 1))
+                }
+                si.scrollRectToVisible(r)
                 break
             }
             norigin = Offset(norigin.inQueue + incr, start)