hecal3 / vim-leader-guide

295 stars 21 forks source link

Delay in mapping execution #16

Closed ctjhoa closed 8 years ago

ctjhoa commented 8 years ago

Hi there,

I notice some delay between the moment when I have finish to press my keys and the real mapping execution. I think related to what you call timeoutlen.

As I understand vim-leader-guide, when I press some keys, it should check if there some associated mapping (and execute it if some) else it should add a delay to wait another key. If the time limit is reached it should display the guide.

You can try what I say with ctjhoa/spacevim and try to press SPC w v

hecal3 commented 8 years ago

Hey,

I just took a quick look at your problem. I don't think it has anything to do with leader-guide.

The delay also occurs if you press SPC w v as a normal mapping. (quickly, without the guide showing) A a rule of thumb: If the guide-window doesn't show up the guide is not involved. Maybe you could try to remove leader-guide from your setup and see if the problem persists.

timeoutlen is a vim option where you can specify how long vim should wait for additional input before executing a mapping. It's nothing specific to leader guide.

hecal3 commented 8 years ago

I think I see what the problem is:

SPC w v calls <SID>split-window-right SPC w V calls <SID>split-window-right-and-focus

So When pressing SPC w v vim executes the internal mapping <SID>split-window-right. Now vim waits for the -and-focus part of the second mapping.

I don't know if there is a way to ignore this whole timeout procedure for and mappings, other than choosing unambiguous names.

edit: Maybe you could append some special character to the mappings (to signify the end of the mapping) and hide it with the displayfunction later on, so it doesn't show up in the actual guide window.

<SID>split-window-right(SpecialChar) and <SID>split-window-right-and-focus(SpecialChar) No ambiguity here.

ctjhoa commented 8 years ago

Thank you very much for this explanation. I will test this as soon as I can.

ctjhoa commented 8 years ago

It works like a charm. Thanks!