ideavim icon indicating copy to clipboard operation
ideavim copied to clipboard

VIM-1824: surround - remove whitespace with closing bracket

Open trimailov opened this issue 4 months ago • 0 comments

Context:

In vim surround extension closing brackets (}, ], )) should remove whitespace when using cs movement.

Example:

  • Before: { example }
  • Movement: cs{}
  • After: {example}

This doesn't work currently. The text is left unchanged.

Solution:

The bug was because brackets were replaced with a string from SURROUND_PAIRS map, which does not have any context about removing characters.

Inspired from VSCode's VIM plugin^1, I have introduced new class SurroundPair that will carry this context about the need to trim characters.

Disclaimer:

I have never written in Kotlin so solution may be not use best practices, though at least this PR seems to fix the problem and tests are passing.

Ticket:

  • https://youtrack.jetbrains.com/issue/VIM-1824/Vim-Surround-Does-not-remove-whitespace-with-the-closing-bracket

trimailov avatar Oct 10 '24 14:10 trimailov