Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout_millis for nested remap #82

Merged
merged 4 commits into from
Apr 8, 2022
Merged

Add timeout_millis for nested remap #82

merged 4 commits into from
Apr 8, 2022

Conversation

k0kubun
Copy link
Contributor

@k0kubun k0kubun commented Apr 1, 2022

Example

I updated the implementation. This YAML:

keymap:
  - remap:
      j:
        remap:
          k: Esc
        timeout_millis: 200
  • j -> 100ms -> k
    • Esc
  • j -> 300ms -> k
    • j -> k
  • j -> any ms -> l
    • j -> l
  • j -> 200ms
    • j

@cipherlogs
Copy link

cipherlogs commented Apr 1, 2022

That's wonderful. just finished the build and did a couple of tests

here's the config that I have used:

keymap:
  - remap:
      j:
        remap:
          k: Esc
        timeout_millis: 200

the issue is if I click j alone it will never resolve. it stays there... so it makes j unusable in my keyboard

another note: it would be very nice if we can control the default 500ms.

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 1, 2022

another note: it would be very nice if we can control the default 500ms.

For backward compatibility, when it doesn't have a timeout, it doesn't timeout. I think it's natural from how it's configured, too.

@cipherlogs
Copy link

cipherlogs commented Apr 1, 2022

Even if I want to I can't assign a timeout to the first remap
I can't do as the following:

keymap:
  - remap:
      j:
        remap:
          k: Esc
    timeout_millis: 200

Error: "mapping values are not allowed in the context ..."

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 1, 2022

It's top-level, there's nothing to be timed out. All you need is #82 (comment).

@cipherlogs
Copy link

I don't understand, it doesn't work ... pressing j and not pressing the following key in the sequence won't resolve to the normal behaviour of j thus making j in your keyboard not functional.

that's not the behavior of what this feature should achieve.

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 2, 2022

In case I confused you by replying a short meesage,

the issue is if I click j alone it will never resolve. it stays there... so it makes j unusable in my keyboard

I still intend to fix this. However, it doesn't still change the fact that the correct config is:

keymap:
  - remap:
      j:
        remap:
          k: Esc
        timeout_millis: 200

because of how the indent level impacts which key. timeout_millis in the above YAML timeouts j, so if you're interested in the timeout of j, that's what you need.

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 2, 2022

I updated the implementation. This YAML:

keymap:
  - remap:
      j:
        remap:
          k: Esc
        timeout_millis: 200

behaves like:

  • j -> 100ms -> k
    • Esc
  • j -> 300ms -> k
    • j -> k
  • j -> any ms -> l
    • j -> l

@cipherlogs
Copy link

cipherlogs commented Apr 2, 2022

Hello, the config is working as expected now.
however there's still the issue of j not resolving if it's not followed by another key.

for example
right now I cannot use my hjkl in vim because it will stuck on j

below is the only behavior that's missing

j -> 200ms or more, user didn't follow with another key press ...

  • j

Thank you.

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 2, 2022

I updated the implementation. This YAML:

keymap:
  - remap:
      j:
        remap:
          k: Esc
        timeout_millis: 200

behaves like:

  • j -> 100ms -> k
    • Esc
  • j -> 300ms -> k
    • j -> k
  • j -> any ms -> l
    • j -> l
  • j -> 200ms
    • j

@cipherlogs
Copy link

I'm running on the new implementation, so far it is working great.

Give me a couple of days to test it and I'll report if something
misbehaves.

Thank you so much!

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 7, 2022

Maybe it's time to release this?

@cipherlogs
Copy link

Yes, just merge the branch. I'm very happy with the results.
Thank you.

@k0kubun
Copy link
Contributor Author

k0kubun commented Apr 8, 2022

Thank you for your patience and testing.

@k0kubun k0kubun marked this pull request as ready for review April 8, 2022 03:46
@k0kubun k0kubun merged commit 18b68bc into master Apr 8, 2022
@k0kubun k0kubun deleted the remap-timeout branch April 8, 2022 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants