-
Notifications
You must be signed in to change notification settings - Fork 249
Fix 806 regression #827
Fix 806 regression #827
Conversation
|
@jacekkopecky Could you explain why we need specific code for handling mouse dragging, rather than treating it like any other means of updating selections? I thought the problem was just that we prevent cursors from moving to the end of the line, even if they have non-empty selections. |
|
Here's what I think happens on mouse dragging in normal mode:
|
In the unusual case that a line already has a cursor on the last character and another comes to the end of the line and `ensureCursorsWithinLine` moves it, we can end up with two cursors in the same place. That’s undesirable. This can happen for example when moving only one of multiple cursors (see joseramonc/multi-cursor#4).
|
@jacekkopecky Can you verify that this fixes the |
|
@maxbrunsfeld yes, I've just verified it. The For non-vim-mode commands, we notice something has happened with the |
|
it means, though, that a command like |
this way the update happens before a redraw; but the specs still need to use setTimeout because animation frames don’t actually happen without a window.
|
@maxbrunsfeld the last comment removes the short cursor flicker on native commands such as |
|
Hooking into the I think that instead, we should hook into the lifecycle of Atom's commands. Basically, we'll only need to adjust the cursor position at two times: after mouse dragging ends (exactly the way you have it now), and after each command runs. Then I don't think we'll need to use In the above |
|
Because we don't have a good |
|
I did a little work on this, and it seemed like checking EDIT: oops, |
|
got it, that should work, thanks |
|
I now got rid of all the cursor/selection change listeners (which required a few spec changes), but it works now (with my recent enough clone of Atom, anyway). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you can remove the if @mode is 'normal' here, since ::ensureCursorsWithinLine internally guards that the mode is normal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite right; in fact, now it's the check in ensureCursorIsWithinLine that's no longer necessary so I removed that one instead.
|
❤️ This is looking really good. Really excited to get this 🚢ed once Atom 1.0.8 is out. |
|
@maxbrunsfeld @jacekkopecky I've been following this thread for a while. Thank you for your hard work! |
|
Thank you for your kind words!
Oops, just remembered that I have a check for existence of onDidDispatch
that shouldn't be there; can remove it in an hour.
|
|
Actually @jacekkopecky I would say leave that in there for a little while. Maybe put a TODO comment to remove it. That way, users w/ old versions of Atom won't get exceptions when they upgrade vim-mode; they just won't have the cursor adjusted. |
|
Hmmm, I'll have to check the amount of breakage that causes in 1.0.7. If
it's usable, you're right.
|
|
Yup, seems usable all right |
|
✨ |
|
Yay! Thank you! |
Fixes #806 and #826 and #829.
I don't know how to add specs for the mouse movements but they are fixed too. @maxbrunsfeld please advise if you would like those specs and know how to do them.