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

Implement ; and , #674

Merged
merged 10 commits into from
Sep 3, 2016
Merged

Implement ; and , #674

merged 10 commits into from
Sep 3, 2016

Conversation

aminroosta
Copy link
Contributor

Related Issue #410

@rebornix @johnfn please let me know if you want me to change something in this PR.

@johnfn
Copy link
Member

johnfn commented Aug 30, 2016

First of all, thank youuu for implementing this! This is a big one that a lot of people want, and I'm super excited to get it in VSCodeVim!

I have some suggestions for improvement. Let me know what you think.

  1. Do not have a BaseRepeatableMovement subclass.
  2. In order to determine the reverse, simply make a mapping from motions to reverse motions. It might look something like this:
const reverseMotionMapping = {
    MoveFindForward: MoveFindBackward,
    MoveFindBackward: MoveFindForward,

    /* etc... */ 
}

Now you don't have to duplicate the keypress assignment and all the information about reversing is clustered together.

@aminroosta
Copy link
Contributor Author

@johnfn As always great feedback 👍
PR is now updated accordingly.

@johnfn
Copy link
Member

johnfn commented Aug 30, 2016

Last suggestion: instead of VimState.lastRepeatableMovement = this inside the body of the exec statement, my suggestion would be to have a property on BaseMotion called something like repeatableWithSemicolonOrComma (feel free to come up with a better name if you wish) and set that to true on the related motions (tTfF).

Then after we execute movements, check if that flag is set on the movement we just ran and if so then run VimState.lastRepeatableMovement = this.

Kind of hard to explain exactly why I think this is better but I like a more declarative approach of specifying important characteristics of actions as properties on the class rather than in the body of the function (where it's harder to find). I think it improves readability.

@aminroosta
Copy link
Contributor Author

@johnfn No wonder that this project has a readable and clean codebase ;)
PR updated accordingly.

@johnfn
Copy link
Member

johnfn commented Aug 31, 2016

:)

Can you actually make it a property on the class directly, sort of like right under

class MyActionThing extends BaseMovement {
   keys = ["f", "<character>"];

you have

repeatableWithSemicolonOrComma = true

?

@aminroosta
Copy link
Contributor Author

@johnfn repeatableWIthSemicolonOrComma should only be set to true if the action is successfully performed and there is no operator like "dfa"

@aminroosta
Copy link
Contributor Author

@johnfn Based on our discussion in slack channel PR updated.

@johnfn
Copy link
Member

johnfn commented Sep 2, 2016

Last thing, I promise! (Sorry for the delay!)

Can you condense it down to one line in the 4 cases where it appears?

return !vimState.recordedState.operator || !(isIMovement(result) && result.failed);

Then we should legitimately be good to go here.

@aminroosta
Copy link
Contributor Author

@johnfn Done 😄

@johnfn
Copy link
Member

johnfn commented Sep 3, 2016

I'm ready to merge this, I just need it to be up to date with master.

@aminroosta
Copy link
Contributor Author

@johnfn Done

@johnfn johnfn merged commit 69ff80c into VSCodeVim:master Sep 3, 2016
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.

2 participants