Commit Graph

21 Commits (52a43bcdfcc258a2871be468a3e31496dd2d80c8)

Author SHA1 Message Date
ZJPzjp 3b8c15618f
Fix warnings from clippy (#7013)
* Fix warnings from clippy

* revert MAIN_SEPARATOR_STR
2023-05-11 14:44:52 +09:00
Kyle Smith 3849ca4c2a
Add test cases for existing pair matching logic. (#6027)
* Add test cases for existing pair matching logic.

* fix clippy
2023-03-08 11:10:55 +09:00
Daniel S Poulin 6929a12f29
Make `m` textobject look for pairs enclosing selections (#3344)
* Make `m` textobject look for pairs enclosing selections

Right now, this textobject only looks for pairs that surround the
cursor. This ensures that the pair found encloses each selection, which
is likely to be intuitively what is expected of this textobject.

* Simplification of match code

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* Adjust logic for ensuring surround range encloses selection

Prior, it was missing the case where the start of the selection came
before the opening brace. We also had an off-by-one error where if the
end of the selection was on the closing brace it would not work.

* Refactor to search for the open pair specifically to avoid edge cases

* Adjust wording of autoinfo to reflect new functionality

* Implement tests for surround functionality in new integration style

* Fix handling of skip values

* Fix out of bounds error

* Add `ma` version of tests

* Fix formatting of tests

* Reduce indentation levels for readability, and update comments

* Preserve each selection's direction with enclosing pair surround

* Add test case for multiple cursors resulting in overlap

* Mark known failures as TODO

* Make tests multi-threaded or they fail

* Cargo fmt

* Fix typos in integration test comments

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-02-10 13:52:57 -06:00
Blaž Hrastnik c2c1280f02
Resolve a bunch of upcoming clippy lints 2022-11-04 21:06:28 +09:00
Ryan Russell ae12c58f0f
Improve Readability (#2639) 2022-06-01 12:01:37 -05:00
Gokul Soumya 22ae1b92a6 Fix tests for surround primitives 2022-04-29 15:51:14 +09:00
Gokul Soumya 76175dbd6d Support m in surround delete and replace 2022-04-29 15:51:14 +09:00
Gokul Soumya de15d70171 Add `m` textobject to select closest surround pair 2022-04-29 15:51:14 +09:00
Gokul Soumya c15996aff5
Show surround delete and replace errors in editor (#1709)
* Refactor surround commands to use early returns

* Show surround delete and replace errors in editor
2022-02-28 17:56:39 +09:00
Omnikar f064894e57
Fix Clippy lints in tests (#1563)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-01-23 16:37:23 +09:00
Gokul Soumya dc53e65b9e
Fix surround cursor position calculation (#1183)
Fixes #1077. This was caused by the assumption that a block
cursor is represented as zero width internally and simply
rendered to be a single width selection, where as in reality
a block cursor is an actual single width selection in form and
function.

Behavioural changes:

1. Surround selection no longer works when cursor is _on_ a
    surround character that has matching pairs (like `'`
    or `"`). This was the intended behaviour from the start
    but worked till now because of the cursor position
    calculation mismatch.
2021-11-29 10:33:53 +09:00
Nathan Vegdahl c9cbc344fc Fix buggy surround behavior from #376.
Fixes #543.
2021-08-04 09:55:59 +08:00
Nathan Vegdahl f96b8b769b Switch to a cleaner range-head moving abstraction.
Also fix a bunch of bugs related to it.
2021-07-24 07:44:11 -07:00
Nathan Vegdahl b4c59b444c Update surround commands to work with gap indexing. 2021-07-08 16:47:20 -07:00
Ivan Tham 6ccfa229ed Fix typo on comment in surround 2021-07-03 20:20:24 +08:00
Gokul Soumya 351c1e7e55 Fix surround bug when cursor on same pair
For example when the cursor is _on_ the `'` in `'word'`, the cursor
wouldn't move because the search for a matching pair started _from_ the
position of the cursor and simply found itself.
2021-07-03 20:20:24 +08:00
Gokul Soumya 394629ab73 Skip enclosed pairs in surround
Surround operations previously ignored other pairs that are
enclosed within which should be skipped. For example if the
cursor is on the `,` in `{{a},{b}}`, doing `md{` previously
would delete the `{` on the left of `a` and `}` on the right
of `b` instead of the outermost braces. This commit corrects
this behavior.
2021-06-24 13:02:56 +09:00
Gokul Soumya 892c80771a Correctly identify pairs when cursor on pair 2021-06-22 14:27:51 +09:00
Gokul Soumya 86271bac18 Refactor and add tests for surround 2021-06-22 14:27:51 +09:00
Gokul Soumya 4754b2e5ae Add more surround pair characters 2021-06-22 14:27:51 +09:00
Gokul Soumya 13648d28b9 Add surround keybinds 2021-06-22 14:27:51 +09:00