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

Add support for 'U' uppercase #312

Merged
merged 1 commit into from
Jun 24, 2016
Merged

Add support for 'U' uppercase #312

merged 1 commit into from
Jun 24, 2016

Conversation

rebornix
Copy link
Member

Convert selected range to Uppercase is an often-used command.

The code is well designed so it's easy enough to add new commands support. The only catch is all commands are implemented inside a single file, which makes it lack of categorization and readability, any ideas to refactor it?

@johnfn
Copy link
Member

johnfn commented Jun 18, 2016

Hey @rebornix, thanks for the awesome PR! I'm glad to hear that the code is easy to understand for the most part.

I hear you about the gigantic file. Honestly, for whatever reason, I've always had a lower sensitivity to this issue than other people, which is why I haven't split it yet. When I tried briefly, I was having difficulty with decorators and splitting actions.ts into multiple files - I think TypeScript decorators may have some implementation bugs (they are classified as experimental, after all).

TL;DR - I'm totally open to PRs that split it up. It's a task I plan to do at some point, but it's not high priority. If a couple people nag me to do it, I'll bump the priority 😉

@@ -43,6 +43,42 @@ const compareKeypressSequence = function (one: string[], two: string[]): boolean
return true;
};

const adjustVimSelectionPosition = function(vimState: VimState, start: Position, end: Position): any {
Copy link
Member

Choose a reason for hiding this comment

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

Two comments here:

  • adjustVimSelectionPosition is an ambiguous name. Something like transformRangeForDeleteOperator might be better.
  • Instead of any I would prefer using a TypeScript tuple type: [Position, Position]

Copy link
Member

Choose a reason for hiding this comment

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

Also I generally prefer static functions to free-floating ones. When we split this file up into many files, the decision will make our lives easier. 😃

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the naming suggestion, it's always pain for non-English speaker like me :) The strict return type suggestion is also good, will change it later.

@johnfn
Copy link
Member

johnfn commented Jun 18, 2016

Last thing - would you mind adding a few tests?

@rebornix
Copy link
Member Author

@johnfn thanks for your detailed review and suggestion. I tried to run test cases on my Windows Machine previously but seems VS Code package will download Linux related package instead. I'll look into it and add tests 😃

@rebornix
Copy link
Member Author

I've tried to move the start/end swapping for Visual mode but failed. The reason is that this will breaks deletion.

  1. Delete Operator may be triggered by executeOperator or runAction, while we don't have any position information inside runAction, so we have to keep the swapping inside Delete Operator.
  2. With above info in mind, we have the swapping inside Delete Op. So putting the swapping inside executeOperator will lead to the duplication of swapping for Delete Op as executeOperator might trigger Delete Op as well.

So the temporary solution for UpperCase operator is reusing the swapping method. This is caused by my limited knowledge of Action/Operator relationships and the workflow, once I have better understanding of the code, I may come up with a prettier solution.

@johnfn
Copy link
Member

johnfn commented Jun 22, 2016

Hmm, I see. I will dig into this tomorrow and see what I can figure out!

@johnfn johnfn merged commit 32174af into VSCodeVim:master Jun 24, 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