vim: Fix change surround with any brackets text object (#37386)

This commit fixes an issue with how the `AnyBrackets` object was handled
with change surrounds (`cs`). With the keymap below, if one was to use
`csb{` with the text `(bracketed)` and the cursor inside the
parentheses, the text would not change.

```json
{
  "context": "vim_operator == a || vim_operator == i || vim_operator == cs",
  "bindings": {
    "b": "vim::AnyBrackets"
  }
}
```

Unfortunately there was no implementation for finding a corresponding
`BracketPair` for the `AnyBrackets` object, meaning that, when using
`cs` (change surrounds) the code would simply do nothing.

This commit updates this logic so as to try and find the nearest
surrounding bracket (parentheses, curly brackets, square brackets or
angle brackets), ensuring that `cs` also works with `AnyBrackets`.

Closes #24439

Release Notes:

- Fixed handling of `AnyBrackets` in vim's change surrounds (`cs`)
This commit is contained in:
Dino
2025-09-02 16:03:14 -07:00
committed by GitHub
parent 7aecab8e14
commit e5a968b709
2 changed files with 190 additions and 67 deletions
+1 -1
View File
@@ -1510,7 +1510,7 @@ pub fn end_of_paragraph(map: &DisplaySnapshot, display_point: DisplayPoint) -> D
map.max_point()
}
fn surrounding_markers(
pub fn surrounding_markers(
map: &DisplaySnapshot,
relative_to: DisplayPoint,
around: bool,