notomo / gesture.nvim

Mouse gesture plugin for neovim
MIT License
527 stars 2 forks source link

[Feature Request] Improve double-click detection #39

Closed beelzebielsk closed 1 year ago

beelzebielsk commented 1 year ago

Vim/Neovim's double-click detection is frustrating. Sometimes it will miss a double-click because my finger moved slightly. I use vim often on a touchscreen device, so it's a problem for me.

Could you improve double-click detection? Do you consider that within scope of your plugin? I was thinking you could consider it a gesture. If not, let me know and I'll either make my own plugin or open an issue with neovim.

I believe the problem is both clicks have to happen in the same cell on screen. Some concrete ideas I have for improving detection:

beelzebielsk commented 1 year ago

This can be extended for triple and quadruple clicks, too.

notomo commented 1 year ago

Thanks interesting request!

But, I think the feature should be implement by other plugin. Even if implemented in a way that fits the current interface, the accuracy may not be satisfactory.

📝 didn't work experimental code.

local gesture = require("gesture")

vim.keymap.set("n", "<LeftMouse>", function()
  gesture.draw({ length_thresholds = { x = 0, y = 0 } })
  gesture.suspend()
end, { silent = true })

gesture.register({
  name = "test",
  inputs = { gesture.up({ max_length = 3 }), gesture.up({ max_length = 3 }) },
  action = function()
    print("test")
  end,
  nowait = true,
})
diff --git a/lua/gesture/core/point.lua b/lua/gesture/core/point.lua
index 01e83e1..8aa4abd 100644
--- a/lua/gesture/core/point.lua
+++ b/lua/gesture/core/point.lua
@@ -21,7 +21,7 @@ function Point.line_to(self, point)
   if length_x > length_y then
     direction = diff_x > 0 and RIGHT or LEFT
     length = length_x
-  elseif length_y >= length_x and length_y > 0 then
+  elseif length_y >= length_x then
     direction = diff_y > 0 and DOWN or UP
     length = length_y
   else
beelzebielsk commented 1 year ago

Thanks! I appreciate the feedback.