-
-
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
Word in visual mode #385
Word in visual mode #385
Conversation
@@ -5,9 +5,14 @@ import { ModeHandler } from '../../src/mode/modeHandler'; | |||
import { setupWorkspace, cleanUpWorkspace, assertEqualLines, assertEqual } from './../testUtils'; | |||
import { ModeName } from '../../src/mode/mode'; | |||
import { TextEditor } from '../../src/textEditor'; | |||
import { getTestingFunctions } from '../testSimplifier'; |
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! I need to change the other tests at some point...
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.
Oh we can do this step by step. Each time we add new test cases to old ones, we can do the tweaking at the same time.
Add logic for Just like I mentioned above, selecting words, sentences, paragraphs, etc all share the same In summary, |
51c281d
to
5b889b2
Compare
Just realize that |
5b889b2
to
a7f321c
Compare
Update and fix conflicts |
a7f321c
to
a4357a9
Compare
let result: Position | IMovement = new Position(0, 0); // bogus init to satisfy typechecker | ||
======= |
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.
There are still some merge conflicts here.
Sorry, I've left this hanging for too long. Can you explain what you did? Just add counts for aw iw? |
a4357a9
to
f672298
Compare
The first thing I did is fixing |
@@ -171,7 +171,12 @@ export abstract class BaseMovement extends BaseAction { | |||
*/ | |||
public async execActionWithCount(position: Position, vimState: VimState, count: number): Promise<Position | IMovement> { | |||
let recordedState = vimState.recordedState; | |||
let result: Position | IMovement = new Position(0, 0); // bogus init to satisfy typechecker | |||
let resultPosition: Position = new Position(0, 0); |
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.
Isn't resultPosition
the exact same thing as position
?
f672298
to
87a8990
Compare
Fix the comment by @johnfn , I was doing wrong with Union Type but now turned around. |
if (lastIteration) { | ||
(result as IMovement).stop = temporaryResult.stop; | ||
} else { | ||
position = temporaryResult.stop.getRightThroughLineBreaks(); |
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.
This getRight concerns me. Why is it necessary?
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.
yup, it's necessary for IMovment. This is also why the logic of IMovement and Position is totally different.
When we run a single movement without an operator, like w
, we want to move cursor to the beginning of next word. While if we run a single movement with an operator, like aw
, we want to move the end cursor to the end of current word (aka, the left-side character of the beginning of next word). Then we sucessfully get a selection of the whole word.
Above is about single movement w/ operator. Then if we run movements with an operator multple times, like 2aw
, after running the first aw
, the end of seletion or the cursor is at the end of first word. As we need to include next following word into the selection, we need to pass the position of the begining of next word to aw
command, then we can get the correct end position of the second aw
. Lastly, we combine the beginning of first word and the end of last word and return the result selection.
Like I mentioned before, Movement (contains a start and a stop) is likely a selection. When executing selection with numeric prefix, I think we always need to move cursor to next character of the end of current selection.
Just want to hear back on my 2 comments and we should be good to merge! |
87a8990
to
f391e53
Compare
@johnfn rebased code and replied to your comments :) |
f391e53
to
7c67e7d
Compare
7c67e7d
to
6c779f5
Compare
Rebase again to resolve conflicts. |
Woo finally! Sorry for taking so long, and thanks @rebornix! |
aw
withexecuteWithOperator
andexecuteWithCount
aW
iw
iW