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

Element motion problems (does not work with selection=exclusive in gvim) #4

Open
oskarkv opened this issue May 7, 2014 · 13 comments
Open

Comments

@oskarkv
Copy link

oskarkv commented May 7, 2014

Maybe these things are just happening for me, because of some other plugin or settings, but...

In the following, |x| represents the cursor position, and <x> represents a visual selection.

Starting with (+ 10|0|0) and doing vae results in (+< 100>0).
Starting with (+ sym|b|ol) and doing vae results in (+< symbo>l).
Starting with something "a str|i|ng" and doing vae results in something< "a string>".

There are similar problems with ie motions. In summary, the element motion does not quite work for the last element in a list, or if the element is a string.

@guns
Copy link
Owner

guns commented May 7, 2014

Hmm, I can't reproduce those unfortunately. I am highly interested in correcting behavior like this, so I would definitely enjoy having a consistently reproducible case. Have these motions always worked like this for you?

There is an outstanding bug in vim-sexp related to registers, but this does not seem to be related.

Thanks for reporting! I hope you will be able to communicate this problem to me.

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

I have not used vim-sexp before, so there is no "always". :P

I tried removing all my plugins except for these: rainbow_parentheses vim-classpath vim-clojure-highlight vim-clojure-static vim-fireplace vim-sexp

Also, I tried it in a really simple Clojure file with just one function.

Here is my vimrc: https://gist.github.com/oskarkv/7759c917238d1c4a90d9

The result is the same as before. Tell me if there is anything else I can do.

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

I don't know why I didn't do this at first...

I deleted everything in my vimrc from line 9 and down (in the above gist). Still the same result.

@guns
Copy link
Owner

guns commented May 7, 2014

Ah, that simplifies things. I was just perusing your vimrc. You use Colemak! Very fascinating, how do you like this layout?

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

Hehe. Colemak is pretty nice. I switched from Qwerty because I had bad habits on there, and starting with a new layout completely seemed easier than unlearning those habits. I like Colemak a lot better than Dvorak though, because Colemak has z, x, c and v in the same positions as Qwerty, and even beyond that I think it's better.

When I did that, I also switched place between Alt Gr and Caps Lock, and put all non-letter symbols on Alt Gr+letters. So this is my home row when I hold Caps Lock: /()@#+-'~ See http://i.imgur.com/2bug7fA.png The hardest symbol to type for me is 6 now. :P

@guns
Copy link
Owner

guns commented May 7, 2014

So this is my home row when I hold Caps Lock: /()@#+-'~

Now that's a pretty big advantage! I'll have to try that someday. And using a new keyboard layout to unlearn bad habits is an interesting strategy.

I hope you don't mind, but I'd like to debug this from scratch. It looks like we have pretty different environments, so I put up a minimal repo for testing and added you as a collaborator:

https://github.com/guns/vim-sexp-issue-4-tmprepo/

Please clone this and run

vim -N -u vimrc -U NONE example.clj

from the repo root, then try the element motions again. They work as intended on my machine. Thanks!

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

This line is making all the difference:
source $VIMRUNTIME/mswin.vim
With it, none of the versions work. Without it both works.
Here mswin.vim is, if you don't have it: https://gist.github.com/oskarkv/ee1ff47184979a828755

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

Actually, it's the behave mswin, but it was in mswin.vim too. With it, the cursor is narrow and in between the letters in visual mode, and it does not reach behind the last letter.

@guns
Copy link
Owner

guns commented May 7, 2014

I was hoping it wasn't mswin.vim. I don't have access to a Windows machine (or even a Windows VM), so I may have to rely on you for testing. Hopefully the reason will be obvious.

Thanks for narrowing it down!

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

Tried :behave mswin?

:be[have] {model}   Set behavior for mouse and selection.  Valid
            arguments are:
               mswin    MS-Windows behavior
               xterm    Xterm behavior

            Using ":behave" changes these options:
            option      mswin           xterm   ~
            'selectmode'    "mouse,key"     ""
            'mousemodel'    "popup"         "extend"
            'keymodel'  "startsel,stopsel"  ""
            'selection' "exclusive"     "inclusive"

That incluse/exclusive stuff sounds like it could be it.

@oskarkv
Copy link
Author

oskarkv commented May 7, 2014

Yes, that was it.

@guns
Copy link
Owner

guns commented May 7, 2014

I just tried it, but it doesn't seem to make any difference; I'll take a look at the vim source

@guns
Copy link
Owner

guns commented May 7, 2014

Okay, I was finally able to reproduce it. This happens in GUI vim only, and only when selection is set to exclusive.

Unfortunately, selection is a global option, so we can't set it to inclusive only for Clojure buffers.

Therefore it looks like I'll have to compensate for the selection option directly in vim-sexp. This is going to take a little bit of work, so for now (if you like), you can

set selection=inclusive

after the final call to behave mswin.

@guns guns changed the title Element motion problems Element motion problems (does not work with selection=exclusive in gvim) May 7, 2014
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

No branches or pull requests

2 participants