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

Problem with non-ascii motion keys #16

Closed
mdhooge opened this issue Apr 8, 2011 · 12 comments
Closed

Problem with non-ascii motion keys #16

mdhooge opened this issue Apr 8, 2011 · 12 comments
Labels

Comments

@mdhooge
Copy link
Contributor

mdhooge commented Apr 8, 2011

While experimenting with the most efficient keys mapping for my own keyboard layout :-D , I've found that some utf-8/non-ascii keys (just a guess) are badly handled; and also the & character.

With the following configuration.
let g:EasyMotion_keys = '&é"''(-è_çà)=azertyuiop$qsdfghjklmù*<wxcvbn,;:!'

The & char is correctly taken into account but not displayed (the original character is highlighted instead).

And I think the algorithm is disturbed by 2-byte characters. When words are separated by a single whitespace, either the red highlight is missing or the motion key is offset by one character.

Not annoying at all, but if it could be corrected, that'd be nice!
Thanks

@Lokaltog
Copy link
Member

Lokaltog commented Apr 8, 2011

I've noticed the problem with non-ASCII keys as well. I created an experimental fix at 3df6a76, but it doesn't work 100% and possibly won't work with the newest versions.

It's on my todo-list, but it's a bit complicated to make n-byte characters work correctly.

@mdhooge
Copy link
Contributor Author

mdhooge commented Apr 8, 2011

If I can vote for an issue, I'd rather prefer you to work on issue #17
:-P

@haya14busa
Copy link
Member

I fixed multibyte handling for the buffer text, but I didn't consider at all for using non-ascii characters as a EasyMotion_keys...

It's probably way to hard to implement because it already support multibyte characters on buffer text and I don't think it's worth to fix (and I don't have non-ascii keyboard).

Anyway, I fixed multibyte handling, so please update and see how it works again?

Thanks

@blueyed
Copy link
Contributor

blueyed commented Feb 10, 2014

@haya14busa
There is still a problem, but only when displaying them (overlay): only the first byte is displayed.

To reproduce it, you can use let g:EasyMotion_keys='asdfäöü'. This should make the problem visible.
For jumping, you should be able to copy'n'paste the char.

I took at quick look at the code.
The following places might have to get changed as well:

    diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim
    index cede8b8..a9a437a 100644
    --- a/autoload/EasyMotion.vim
    +++ b/autoload/EasyMotion.vim
    @@ -826,7 +826,8 @@ function! s:PromptUser(groups) "{{{
             if len(group_values) == 1
                     if mode(1) ==# 'no'
                             " Consider jump to first match
    -            let s:dot_repeat['target'] = g:EasyMotion_keys[0]
    +            " NOTE: matchstr() handles multibyte characters.
    +            let s:dot_repeat['target'] = matchstr(g:EasyMotion_keys, '^.')
                     endif
                     redraw
                     return group_values[0]
    @@ -954,7 +955,8 @@ function! s:PromptUser(groups) "{{{
                     " Jump first target when Enter or Space key is pressed "{{{
                     if (char ==# "\<CR>" && g:EasyMotion_enter_jump_first == 1) ||
                     \  (char ==# " " && g:EasyMotion_space_jump_first == 1)
    -            let char = g:EasyMotion_keys[0]
    +            " NOTE: matchstr() is multibyte aware.
    +            let char = matchstr(g:EasyMotion_keys, '^.')
                     endif "}}}

                     " For dot repeat {{{

@haya14busa
Copy link
Member

Thanks @blueyed

I can reproduce it. However it's maybe hard to fix, so I'll try to fix it later.

The following places might have to get changed as well:

It looks good to me, so If you are ok, whould you mind open a pull request?

blueyed added a commit to blueyed/vim-easymotion that referenced this issue Feb 10, 2014
@Svalorzen
Copy link

I'm having a small problem here too. I have an Italian layout, so I wanted to be able to use the following keys: "èòàùì". Easymotion correctly works, but each of these letters is replaced by "Ã" in the text, so that I can't really disambiguate between them.

@haya14busa
Copy link
Member

Thank you for the report :)

Now, EasyMotion support non-ascii, multibyte key in g:EasyMotion_keys on this branch

https://github.com/Lokaltog/vim-easymotion/tree/handle/multibytetargetkey

like this.

let g:EasyMotion_keys = 'asdfäöüèòàùì'

@Svalorzen, @blueyed Would you mind trying this branch and seeing how it works?

NOTE: I cannot say it works well completely, there are some case which target coordinates go wrong...

@haya14busa
Copy link
Member

NOTE: I cannot say it works well completely, there are some case which target coordinates go wrong...

I fixed it. Maybe it works well completely to merge into master, but to make it sure, I want you to try this branch and see how it works because I don't use non-ascii layout keyboard.

It seems it show non-ascii char well and maybe you can type it.

@Svalorzen
Copy link

I've tested this for a bit and it seems to be working perfectly, at least for what characters I have!

@haya14busa
Copy link
Member

@Svalorzen Thank you for testing 👍

It seems it works well completely for me including handling '&', so I merged it into master.

In addition, I want to add some example of g:EasyMotion_keys including non-ascii chars on help document.

Would you mind telling me how the Italian (or others) layout is correspond with qwerty keyboard layout?

QWERTY layout example

" Easy to type for qwerty layout keyboard
let g:EasyMotion_keys = 'asdfghjklqwertyuiopzxcvbnm'

@Svalorzen
Copy link

@haya14busa No problem! The italian layout is a simple qwerty layout, the difference mostly lays in the keys on the right side (after p, l and m).

A picture is most probably clearer:

Where the [ and ] characters are typed using the Alt-Gr modifier, and the { and } using both Alt-Gr and the right Shift key.

So the default EasyMotion keys are perfectly fine, I was just trying to expand the possibilities with the other keys that are easily reachable in this layout =)

@haya14busa
Copy link
Member

I got it! Thanks for the info @Svalorzen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants