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

Fix #7159 bad handling of auto-surrounding selections #8533

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

Elliot-Roberts
Copy link
Contributor

What this PR does / why we need it:
By default in VSCode with VSCodeVim disabled, selecting text and typing an opening bracket or quote will surround the selection, while keeping the selection, allowing for further non-surrounding keystrokes to overwrite the selected text.

Currently, with VSCodeVim enabled, in insert mode the functionality is still partially present, but broken.
The text gets surrounded, but the selection is lost, and the cursor is placed one character short of the right end.

This is a pain when filling in snippet holes with strings.
I want to be able to just type my new text in, but when VSCodeVim is enabled, if I am inserting a string or bracketed expression, I have to delete the placeholder text first to prevent it from interfering.
e.g. if the selected placeholder is name and I type in "Jeff, I get "namJeffe" when I wanted "Jeff".

This PR fixes the behavior in insert mode to match the vim-disabled behavior.

Which issue(s) this PR fixes
Fixes #7159

Special notes for your reviewer:
I did not get super familiar with the codebase. I hope you can pardon the tacked-on quality of the additions. They at least do not break existing tests, and I'm of course open to suggestions for restructuring.

Thanks :)

Copy link
Member

@J-Fields J-Fields left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@J-Fields J-Fields merged commit 59d55e1 into VSCodeVim:master Aug 29, 2023
0 of 2 checks passed
@szechp
Copy link

szechp commented Sep 14, 2023

is there a way to improve this to add surroundings for visual selections? right now i have to go to insert mode, shift select and then press " to surround a word.

@Elliot-Roberts
Copy link
Contributor Author

VSCodeVim includes emulation of the surround.vim vim plugin, which is a popular solution for surrounding in vim. Does that work for you?
The auto-surrounding behavior in insert mode comes from VSCode natively and operates on "VSCode-style" selections.
Visual mode selections are a vim concept, and so have a more vim-style solution.

@szechp
Copy link

szechp commented Sep 14, 2023 via email

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.

Surrounding selection with quotes
3 participants