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

VIM-1824: surround - remove whitespace with closing bracket #1007

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trimailov
Copy link

@trimailov trimailov commented Oct 10, 2024

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 plugin1, 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:

Footnotes

  1. https://github.com/VSCodeVim/Vim/blob/04fe42aa815f638af14e4cf4c92e88109242c3e6/src/actions/plugins/surround.ts#L455

**Context**:

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

Example:
- Before: `{ example }`
- Movement: `cs{}`
- After: `{example}`

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

**Solution**:

Inspired from VSCode's VIM plugin[^1], I have introduced new class
`SurroundPair` that will carry this context about 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

[^1]: https://github.com/VSCodeVim/Vim/blob/04fe42aa815f638af14e4cf4c92e88109242c3e6/src/actions/plugins/surround.ts#L455
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.

2 participants