diff src/name/blackcap/clipman/SearchDialog.kt @ 29:c4f53bc01732

Fix searching (and main display).
author David Barts <n5jrn@me.com>
date Wed, 29 Jan 2020 14:36:16 -0800
parents f1fcc1281dad
children 0c6c18a733b7
line wrap: on
line diff
--- a/src/name/blackcap/clipman/SearchDialog.kt	Wed Jan 29 13:39:14 2020 -0800
+++ b/src/name/blackcap/clipman/SearchDialog.kt	Wed Jan 29 14:36:16 2020 -0800
@@ -163,8 +163,19 @@
         }
         if (result == null) {
             Toolkit.getDefaultToolkit().beep()
+            origin = null
+        } else {
+            origin = when(direction) {
+                PasteboardQueue.Direction.FORWARDS ->
+                    PasteboardQueue.Offset(result.inQueue, result.inItem + 1)
+                PasteboardQueue.Direction.BACKWARDS ->
+                    if (result.inItem == 0) {
+                        if (result.inQueue == 0) null else PasteboardQueue.Offset(result.inQueue - 1, -1)
+                    } else {
+                        PasteboardQueue.Offset(result.inQueue, result.inItem - 1)
+                    }
+            }
         }
-        origin = result
     }
 
     /* changing the search string resets the search origin */