-
-
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
Multiline yank writes to 0 register; fixes #1214 #3087
Conversation
@@ -302,9 +302,7 @@ export class Register { | |||
*/ | |||
private static processNumberedRegister(content: RegisterContent, vimState: VimState): void { | |||
// Find the BaseOperator of the current actions | |||
const baseOperator = vimState.recordedState.actionsRun.find(value => { | |||
return value instanceof BaseOperator || value instanceof BaseCommand; | |||
}); |
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.
Previously, this code was initializing baseOperator
to be CommandNumber
in some cases. For example, 5Y
is [CommandNumber, CommandYankFullLine]
, and because CommandNumber
inherits from BaseCommand
and comes first, baseOperator
would be set to that.
Then, the blocks below specifically to handle yanks wouldn't be hit.
Vim/src/actions/commands/actions.ts
Line 284 in bd153ad
export class CommandNumber extends BaseCommand { |
@@ -126,7 +126,7 @@ export class RecordedState { | |||
* The command (e.g. i, ., R, /) the user wants to run, if there is one. | |||
*/ | |||
public get command(): BaseCommand { | |||
const list = _.filter(this.actionsRun, a => a instanceof BaseCommand); | |||
const list = _.filter(this.actionsRun, a => a instanceof BaseCommand).reverse(); |
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.
As far as I could tell, this get command()
isn't actually being used anywhere yet, so this should be a safe change.
However, the comment below brought me pause:
// TODO - disregard , then assert this is of length 1.
If there is only supposed to be one BaseCommand
, how come 5Y
is two commands? Not familiar with the VSCode Vim codebase, but just wanted to mention this in case it matters.
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, what are your thoughts on handling this in the processNumberedRegister call instead? Changing this seems a little bit of a workaround since the get() is currently returning the stack the way it was executed (which seems OK to me)
Not too sure on the TODO comment :/
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.
Well, since nobody else seems to be calling get command()
, I guess we can define it however we wish. To me, returning the last command seems to make more sense - for example if I ran 5@q
I'd expect .command
to refer to the macro execution, CommandExecuteMacro
as opposed to CommandNumber
. Or for something like "aD
, I'd expect the D
command, CommandDeleteToLineEnd
, instead of the register command,CommandRegister
.
That said, you know the code better than I do, so happy to do it either way in the end! Both ways will accomplish the same purpose and get this working better which is what matters 😃
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.
Interesting looks like the getter for operator is reversed, lets just go with this!
Thanks! This one actually bugs me a lot! |
Hey @jkillian, TravisCI finished with status TravisBuddy Request Identifier: 9bb6a060-c994-11e8-a6c9-11724a02104f |
Thanks @xconverge! As a sidenote, I found this codebase really easy to jump into and start working on, so big 👍 for the simple code and organization! (And also for TypeScript which helps so much haha) |
👍 ignore that travisbuddy warning, I merged in the middle of a build |
What this PR does / why we need it:
Makes sure that multiline yank commands (
5yy
,5Y
,V%y
) write to the0
register. (They don't currently)Which issue(s) this PR fixes
fixes #1214, fixes #2554, fixes #3065
Special notes for your reviewer:
See inline comment below for more explanation of this change