vim: Surround in visual mode (#13347)

Adds support for surrounding text in visual/visual-line/visual-block
mode by re-using the `AddSurrounds` operator. There is no default
binding though so the user must follow the instructions to enable it.

Note that the behaviour varies slightly for the visual-line and
visual-block modes. In visual-line mode the surrounds are placed on
separate lines (the vim-surround extension also indents the contents but
I opted not to as that behaviour is less important with the use of code
formatters). In visual-block mode each of the selected regions is
surrounded and the cursor returns to the beginning of the selection
after the action is complete.

Release Notes:

- Added action to surround text in visual mode (no default binding).

Fixes #13122
This commit is contained in:
Benjamin Davies 2024-06-25 03:29:06 +12:00 committed by GitHub
parent 5a8c2a4a88
commit 77b2da2b42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 167 additions and 9 deletions

View file

@ -287,7 +287,10 @@ impl EditorState {
.unwrap_or_else(|| "none"),
);
if self.mode == Mode::Replace {
if self.mode == Mode::Replace
|| (matches!(active_operator, Some(Operator::AddSurrounds { .. }))
&& self.mode.is_visual())
{
context.add("VimWaiting");
}
context