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

Remove redundant loop in s:getchar() #232

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rene-descartes2021
Copy link
Collaborator

Changes:

  • Some improvement to s:getchar() pathway, appears the loop there is redundant and erroneous. Redundant with respect to the wait_for_input()->s:handle_input()->s:show_next_level_mappings() recursion which progressively refines s:runtime with:
let s:runtime = a:next_runtime
call which_key#window#show(s:runtime)
  • Bug fixed includes a logic error if s:getchar() accumulates an input longer than one character, as the following call s:handle_input(get(s:runtime, char)) will error as there is no key in s:runtime longer than one character. I'm not sure how this bug doesn't appear to surface, and I suspect that the loop isn't ever entered, but I could be wrong.

@@ -272,17 +261,14 @@ function! s:getchar() abort
return '<CR>'
endif

let input .= which_key#char_handler#parse_raw(c)
if s:has_children(input)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop was introduced to distinguish the mappings like gc and gcc as initially reported in #3, I guess it's still useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I wasn't completely sure what was going on so I left this as a draft till I could figure things out better.

endif
endwhile
let c = which_key#char_handler#parse_raw(c)
if has_key(s:KEYCODES, c)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has been incorporated into #240, thank you!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

liuchengxu added a commit that referenced this pull request Aug 13, 2023
* Convert "\<Tab>" to "<Tab>"

The mapping `<Tab>` is tracked in the mappings in String form, while the
returned value from `getchar()` is a Number, convert it to String
manually so that the corresponding entry in `s:runtime` can be
retrieved.

Close #135

* Handle more special keys properly

Part of #232, Thanks to @rene-descartes2021
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.

None yet

2 participants