[ZeroBrane Studio] Re: zbs-vim plugin

  • From: "Paul Reilly" <pajthbr@xxxxxxxxx>
  • To: "Paul K" <paul@xxxxxxxxxxxxx>
  • Date: Tue, 24 Oct 2017 19:53:41 +0100

Aha, that's it setting with the ID now - thanks very much Paul! Now I can 
switch back and forward from Vim to ZBS as planned.
Cheers!
Paul


&#x200b;
From: Paul K
Received: 24/10/2017 18:52:13 +01:00
To: Paul Reilly
CC: zerobrane@xxxxxxxxxxxxx
Hi Paul,

ide:SetHotKey(ID, shortcut)
... using the retrieved ID doesn't restore the previous functionality after
changing the shortcut to a custom one with a previous call to SetHotKey.

It actually works in most cases, except the one you probably care
about here: when SetHotKey is set to a function. It keeps the
accelerator, which continues to work even after the new value is set.
The following patch fixes this issue for me:

diff --git a/src/editor/package.lua b/src/editor/package.lua
index c9ac9e7..a328f0a 100644
--- a/src/editor/package.lua
+++ b/src/editor/package.lua
@@ -1264,6 +1264,10 @@ function ide:SetHotKey(id, ksc)
-- continue with the loop as there may be multiple associations
with the same hotkey
end

+ -- remove an existing accelerator (if any)
+ local acid = self:GetHotKey(ksc)
+ if acid then self:SetAccelerator(acid) end
+
-- if the hotkey is associated with a function, handle it first
if type(id) == "function" then
local fakeid = NewID()

Paul.

Other related posts: