about summary refs log tree commit diff stats
path: root/edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-06-01 12:33:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-06-01 12:37:17 -0700
commit3e848efb081797d2341254dbdfdcccc307cf5170 (patch)
tree5b66eef0b0de0dec047753a0381cefd63ff214bc /edit.lua
parentf1886391c56e530bb1bb362a450aa9ab6cb8485c (diff)
downloadtext.love-3e848efb081797d2341254dbdfdcccc307cf5170.tar.gz
ah, I see the problem
Text.mouse_pos can sometimes set recent_mouse.time but not
recent_mouse.x/y. I'd assumed x/y is never nil in those situations, but
that's violated. It's most easily seen when typing C-a and then
clicking.
Diffstat (limited to 'edit.lua')
-rw-r--r--edit.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/edit.lua b/edit.lua
index 7140997..f9eb076 100644
--- a/edit.lua
+++ b/edit.lua
@@ -223,7 +223,7 @@ end
 
 function edit.mouse_press(State, x,y, mouse_button)
   if State.search_term then return end
-  print_and_log(('edit.mouse_press: cursor at %d,%d').format(State.cursor1.line, State.cursor1.pos))
+  print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
   if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then
     -- press on a button and it returned 'true' to short-circuit
     return
@@ -241,7 +241,7 @@ function edit.mouse_press(State, x,y, mouse_button)
         --  press and hold to start a selection: sets selection on press, cursor on release
         --  press and hold, then press shift: ignore shift
         --    i.e. mouse_release should never look at shift state
-        print_and_log(('edit.mouse_press: in line %d').format(line_index))
+        print_and_log(('edit.mouse_press: in line %d'):format(line_index))
         State.old_cursor1 = State.cursor1
         State.old_selection1 = State.selection1
         State.mousepress_shift = App.shift_down()
@@ -249,7 +249,7 @@ function edit.mouse_press(State, x,y, mouse_button)
             line=line_index,
             pos=Text.to_pos_on_line(State, line_index, x, y),
         }
-        print_and_log(('edit.mouse_press: selection now %d,%d').format(State.selection1.line, State.selection1.pos))
+        print_and_log(('edit.mouse_press: selection now %d,%d'):format(State.selection1.line, State.selection1.pos))
         break
       end
     elseif line.mode == 'drawing' then
@@ -267,7 +267,7 @@ end
 
 function edit.mouse_release(State, x,y, mouse_button)
   if State.search_term then return end
-  print_and_log(('edit.mouse_release: cursor at %d,%d').format(State.cursor1.line, State.cursor1.pos))
+  print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
   if State.lines.current_drawing then
     Drawing.mouse_release(State, x,y, mouse_button)
     schedule_save(State)
@@ -280,12 +280,12 @@ function edit.mouse_release(State, x,y, mouse_button)
     for line_index,line in ipairs(State.lines) do
       if line.mode == 'text' then
         if Text.in_line(State, line_index, x,y) then
-          print_and_log(('edit.mouse_release: in line %d').format(line_index))
+          print_and_log(('edit.mouse_release: in line %d'):format(line_index))
           State.cursor1 = {
               line=line_index,
               pos=Text.to_pos_on_line(State, line_index, x, y),
           }
-          print_and_log(('edit.mouse_release: cursor now %d,%d').format(State.cursor1.line, State.cursor1.pos))
+          print_and_log(('edit.mouse_release: cursor now %d,%d'):format(State.cursor1.line, State.cursor1.pos))
           if State.mousepress_shift then
             if State.old_selection1.line == nil then
               State.selection1 = State.old_cursor1
@@ -301,7 +301,7 @@ function edit.mouse_release(State, x,y, mouse_button)
         end
       end
     end
-    print_and_log(('edit.mouse_release: finally selection %s,%s cursor %d,%d').format(tostring(State.selection1.line), tostring(State.selection1.pos), State.cursor1.line, State.cursor1.pos))
+    print_and_log(('edit.mouse_release: finally selection %s,%s cursor %d,%d'):format(tostring(State.selection1.line), tostring(State.selection1.pos), State.cursor1.line, State.cursor1.pos))
   end
 end