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

WIP: Stay in Insert Mode When Selecting #544

Conversation

killercup
Copy link

As discussed in #479.

This adds a configuration option to restore the previous behaviour; just set "vim.switchToVisualOnSelection": true.

  • Option to stay in insert mode when selecting text; writing replaces selection

  • Support wrapping selection in brackets ((…), […], {…}, <…>) and quotes ('…', "…", )

    If we need to implement this ourselves (instead of leveraging VSCode's default behaviour), we can probably also easily add a "surround" modifier (like vim-surround does), so you can vsiw[ to surround the inner word with angular brackets.

  • Tests

Adds a configuration option to restore the previous behaviour; just set
`"vim.switchToVisualOnSelection": true`.

Concerns VSCodeVim#479

vimState.cursorStartPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);
vimState.cursorPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);
vimState.cursorStartPosition = Position.FromVSCodePosition(cursorPosition);
Copy link
Member

Choose a reason for hiding this comment

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

This change does not seem right to me.

Copy link
Author

Choose a reason for hiding this comment

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

You're right, totally copy-pasta mistake, should be .start.

Actually: Is there a case where we don't want the .cursorPosition (line below) be .selection.end? When would we want the cursor to be at the start of the selecting after inserting text?

Copy link
Member

@johnfn johnfn Aug 1, 2016

Choose a reason for hiding this comment

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

But why would you even need to convert cursorPostition from a vscode position in the first place - it should already be the right type of position.

Copy link
Member

Choose a reason for hiding this comment

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

Actually: Is there a case where we don't want the .cursorPosition (line below) be .selection.end?

Yeah, cursorPosition is generally equal to selection.end. However, we usually don't do that because that would require waiting for VSCode to update the position, which can take a long time. The speed doesn't generally matter that much except for things like . and macros, in which case it becomes very noticeable.

Copy link
Author

Choose a reason for hiding this comment

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

But why would you even need to convert cursorPostition from a vscode position in the first place - it should already be the right type of position.

I didn't dig any deep than:

Type 'vscode.Position' is not assignable to type 'Position'.
  Property '_nonWordCharRegex' is missing in type 'Position'.

Copy link
Member

Choose a reason for hiding this comment

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

My bad. I got confused because generally in VSCodeVim we use cursorPosition
to indicate our own Position variable, so I read the code incorrectly.

On Tue, Aug 2, 2016 at 3:04 PM, Pascal Hertleif notifications@github.com
wrote:

In src/actions/actions.ts
#544 (comment):

  •  vimState.cursorStartPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);
    
  •  vimState.cursorPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);
    
  •  vimState.cursorStartPosition = Position.FromVSCodePosition(cursorPosition);
    

But why would you even need to convert cursorPostition from a vscode
position in the first place - it should already be the right type of
position.

I didn't dig any deep than:

Type 'vscode.Position' is not assignable to type 'Position'.
Property '_nonWordCharRegex' is missing in type 'Position'.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/VSCodeVim/Vim/pull/544/files/e2aa40a22dca3e8d515c0e4628aa5327fa5984da#r73172814,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKPQSPGLAQfqpvmzUpONXD8hjPb6sr1ks5qb1yHgaJpZM4JZrc-
.

Grant

@jpoon jpoon added the WIP label Aug 2, 2016
@peterjuras
Copy link

peterjuras commented Aug 13, 2016

Can this be splitted into two separate PRs? The option alone would really help me in my development workflow.

@johnfn
Copy link
Member

johnfn commented Oct 8, 2016

I think this is no longer necessary, so I'm going to close this one.

@johnfn johnfn closed this Oct 8, 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.

4 participants