8000 Inclusiveness fixes by jacekkopecky · Pull Request #783 · atom/vim-mode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Inclusiveness fixes #783

Merged
merged 5 commits into from
Aug 31, 2015

Conversation

jacekkopecky
Copy link
Contributor

This PR addresses one functionality issue with inclusive motion backwards: inclusive movement backwards should include the character under cursor.

At the moment in vim-mode, only % is an inclusive movement that can go backwards, so only it is affected. When search gets postfixes (basically /e), or when we implement operator-pending v motions (e.g. dvb is an inclusive version of db), other motions too will be affected.

The PR is seemingly more involved than it would have to be, but IMHO it includes useful cleanups:

  1. the operatesInclusively flag in Motion should be false by default because inclusive motions are the exception, the norm is exclusive motions.
  2. I removed the operatesInclusively flag where it's redundant.
  3. I distinguished between non-visual selection for inclusive movements (the rewritten moveSelectionInclusively method on Motion) and selection movement in visual mode (the new moveSelectionVisual, which is the old moveSelectionInclusively): the old logic was really for any movement in visual mode, and while one could amend it to handle the backward exclusive non-visual movements correctly, I really saw it as combining two functionalities in one unnecessarily.
  4. I understood and added comments in the old logic (now moveSelectionVisual) - it was pretty dense code.

The specs are in common with #774, just tweaked for what's fixed here.

Fixes #753.

# differs from VIM, fixed in #774
expect(vimState.mode).toBe "insert"

describe "repeats correctly with .", ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should say something general, like describe "repetition and undo", ->.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

quite right, sorry, don't know what happened there; restructured now.

@jacekkopecky
Copy link
Contributor Author

Ah, specs tripped by the command/normal rename; I'll fix that after #787

@jacekkopecky jacekkopecky force-pushed the check-motion-inclusiveness branch from e1fdc4d to 6744e61 Compare July 23, 2015 16:29
This is better because inclusive operations are the special case.
CurrentSelection doesn’t get operatesInclusively because it redefines
select() anyway.
Conflicts:
	spec/operators-spec.coffee
and add comments, all for code clarity
@jacekkopecky jacekkopecky force-pushed the check-motion-inclusiveness branch from 6744e61 to 2698424 Compare August 17, 2015 22:44
@jacekkopecky
Copy link
Contributor Author

all new and rebased now

@maxbrunsfeld
Copy link
Contributor

Great!

maxbrunsfeld pushed a commit that referenced this pull request Aug 31, 2015
@maxbrunsfeld maxbrunsfeld merged commit f218c3c into atom:master Aug 31, 2015
@jacekkopecky jacekkopecky deleted the check-motion-inclusiveness branch August 31, 2015 16:43
t9md added a commit to t9md/vim-mode that referenced this pull request Sep 8, 2015
t9md added a commit to t9md/vim-mode that referenced this pull request Sep 11, 2015
Different approach to atom#783.
For me visual Characterwise is exactly inclusiveSelection.
So semantically treating this as one functionality is natural.
I understand its complicate things maybe, if it became complicated, I
will separate function at then.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

% motion composing with d command
2 participants
0