-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
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 { |
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.
Two comments here:
adjustVimSelectionPosition
is an ambiguous name. Something liketransformRangeForDeleteOperator
might be better.- Instead of
any
I would prefer using a TypeScript tuple type:[Position, Position]
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.
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. 😃
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.
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.
Last thing - would you mind adding a few tests? |
@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 😃 |
I've tried to move the start/end swapping for Visual mode but failed. The reason is that this will breaks deletion.
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. |
Hmm, I see. I will dig into this tomorrow and see what I can figure out! |
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?