-
-
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
Multi-Cursor Mode v 2.0 #811
Conversation
I can't believe I actually got it to work.
Conflicts: src/register/register.ts
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.
Got through only a couple of the changes, but posting them first.
@@ -13,8 +13,12 @@ | |||
} | |||
], | |||
|
|||
"vim.hlsearch": false, |
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.
should we be checking in these settings? They are very much user-specific.
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.
My settings.json is objectively the best though... 😉
Okay, okay, we should probably add it to .gitignore. :P
@@ -254,6 +258,17 @@ export abstract class BaseCommand extends BaseAction { | |||
*/ | |||
isCompleteAction = true; | |||
|
|||
supportsMultiCursor = true; | |||
|
|||
multicursorIndex: number | undefined = undefined; |
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.
Nitpicking: I feel like you should capitalize the 'c'
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.
hmm, i am being inconsistent here...
/** | ||
* In multi-cursor mode, do we run this command for every cursor, or just once? | ||
*/ | ||
public runsOnceForEveryCursor(): boolean { |
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.
Can this be a property instead?
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.
Ah, I see why you did it this way.
|
||
for (let i = 0; i < timesToRepeat; i++) { | ||
vimState = await this.exec(position, vimState); | ||
let timesToRepeat = this.canBePrefixedWithCount ? vimState.recordedState.count || 1 : 1; |
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 is the same as line 288? Can we execute this once outside the if block?
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.
Yeah, good point.
let resultingCursors: Range[] = []; | ||
let i = 0; | ||
|
||
const cursorsToIterateOver = vimState.allCursors |
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.
Mind leaving a comment here about what's happening? This looks super magical to me :)
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.
I actually explained what was going on over here:
Unfortunately I had to have similar logic in 2 places but I think the alternative is even worse. :P
Conflicts: src/register/register.ts
The other one got way out of control because I was trying to refactor the entire codebase. Undoing all that insanity and cutting it down to basics!