about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/edit.lua b/edit.lua
index 8383a11..af04832 100644
--- a/edit.lua
+++ b/edit.lua
@@ -177,7 +177,7 @@ function edit.mouse_release(State, x,y, mouse_button)
 --?   print_and_log(('edit.mouse_release(%d,%d): cursor at %d,%d'):format(x,y, State.cursor1.line, State.cursor1.pos))
   State.mouse_down = nil
   if y < State.top then
-    State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
+    State.cursor1 = deepcopy(State.screen_top1)
     edit.clean_up_mouse_press(State)
     return
   end
@@ -216,7 +216,7 @@ end
 
 function edit.mouse_wheel_move(State, dx,dy)
   if dy > 0 then
-    State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
+    State.cursor1 = deepcopy(State.screen_top1)
     for i=1,math.floor(dy) do
       Text.up(State)
     end
@@ -258,6 +258,9 @@ function edit.keychord_press(State, chord, key)
       local len = utf8.len(State.search_term)
       local byte_offset = Text.offset(State.search_term, len)
       State.search_term = string.sub(State.search_term, 1, byte_offset-1)
+      State.cursor = deepcopy(State.search_backup.cursor)
+      State.screen_top = deepcopy(State.search_backup.screen_top)
+      Text.search_next(State)
     elseif chord == 'down' then
       State.cursor1.pos = State.cursor1.pos+1
       Text.search_next(State)