tool-bar icon indicating copy to clipboard operation
tool-bar copied to clipboard

don't always set `tooltip.keyBindingCommand`

Open aminya opened this issue 5 years ago • 6 comments

  • Fixes #307
  • Almost doubles the speed of button creation (X2 faster)
  • See https://github.com/suda/tool-bar/issues/307#issuecomment-641719848 for the reason

Button creation time:

After: 2020-06-10 00_01_00-Timecop — C__Users_yahyaaba_Documents_GitHub_JavaScript_tool-bar — Atom

Before: image

This is not shown in the loading time of tool-bar since other packages add buttons using the service, but instead, it can be easily measured using window.performance.now()

aminya avatar Jun 10 '20 04:06 aminya

I'm personally not a fan of this, as it actually changes the tool-tip as seen here:

Before After
before after

I would be fine with adding it as an option though.

ericcornelissen avatar Jun 11 '20 13:06 ericcornelissen

I'm personally not a fan of this, as it actually changes the tool-tip as seen here:

Before After before after I would be fine with adding it as an option though.

We can certainly make a PR to Atom, and see why this key-binding adding takes time. I uploaded the branch that I ported the Atom's tooltip function: https://github.com/aminya/tool-bar/blob/df0436db663e401471ea4acd4fd6f599f5ada84b/lib/items/tool-bar-button-view.js#L254-L325

We can also add the key-binding to the actual text instead of going through Atom's code.

tooltip.title = tooltip.title + this.options.callback

aminya avatar Jun 11 '20 14:06 aminya

We can certainly make a PR to Atom, and see why this key-binding adding takes time.

I prefer that 100% over just removing this feature from the tool-bar. But it's probably because it needs to find the keybind value in a rather large set of callback possibilities, though that doesn't mean it cannot be optimized.

We can also add the key-binding to the actual text instead of going through Atom's code.

tooltip.title = tooltip.title + this.options.callback

That won't work. The callback value, in the case if-branch you removed is entered, is not the keybind string itself, it is the command name.

ericcornelissen avatar Jun 11 '20 17:06 ericcornelissen

We can certainly make a PR to Atom, and see why this key-binding adding takes time.

I prefer that 100% over just removing this feature from the tool-bar. But it's probably because it needs to find the keybind value in a rather large set of callback possibilities, though that doesn't mean it cannot be optimized.

We can also add the key-binding to the actual text instead of going through Atom's code.

tooltip.title = tooltip.title + this.options.callback

That won't work. The callback value, in the case if-branch you removed is entered, is not the keybind string itself, it is the command name.

I see. Thanks for the clarification. We can look into the actual function. The performance is not that bad though, but we may able to boost it a bit.

aminya avatar Jun 11 '20 17:06 aminya

I see. Thanks for the clarification. We can look into the actual function. The performance is not that bad though, but we may able to boost it a bit.

That means we can close this PR, right?

Again, though, I'm not against adding an option that disables this feature 😉

ericcornelissen avatar Jun 11 '20 17:06 ericcornelissen

Let's keep it open for the future reference. If I close it, it might get lost 😄

aminya avatar Jun 11 '20 17:06 aminya