Commit Graph

303 Commits (b4c59b444cc4963f95a95fe10f166e58ef857288)

Author SHA1 Message Date
Nathan Vegdahl b4c59b444c Update surround commands to work with gap indexing. 2021-07-08 16:47:20 -07:00
Nathan Vegdahl 753f7f381b Implement `Range::put()` which manages range movements and extensions.
In particular, this wraps the annoying logic involved in keeping the
cursor width to 1 grapheme.
2021-07-07 17:24:39 -07:00
Nathan Vegdahl 85d5b399de Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 2021-07-05 20:27:49 -07:00
Nathan Vegdahl 6e15c9b874 Make vertical selection movement work properly. 2021-07-05 18:58:33 -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 c68fe1f2a3
Add object selection (textobjects) (#385)
* Add textobjects for word

* Add textobjects for surround characters

* Apply clippy lints

* Remove ThisWordPrevBound in favor of PrevWordEnd

It's the same as PrevWordEnd except for taking the current char
into account, so use a "flag" to capture that usecase

* Add tests for PrevWordEnd movement

* Remove ThisWord* movements

They did not preserve anchor positions and were only used
for textobject boundary search anyway so replace them with
simple position finding functions

* Rewrite tests of word textobject

* Add tests for surround textobject

* Add textobject docs

* Refactor textobject word position functions

* Apply clippy lints on textobject

* Fix overflow error with textobjects
2021-07-03 10:07:49 +09:00
Nathan Vegdahl 28d2d68804 Make horizontal selection movement work properly. 2021-07-02 09:51:29 -07:00
Kirawi c5b2973739
`:reload` (#374)
* reloading functionality

* fn with_newline_eof()

* fmt

* wip

* wip

* wip

* wip

* moved to core, added simd feature for encoding_rs

* wip

* rm

* .gitignore

* wip

* local wip

* wip

* wip

* no features

* wip

* nit

* remove simd

* doc

* clippy

* clippy

* address comments

* add indentation & line ending change
2021-07-02 23:54:50 +09:00
Nathan Vegdahl 22dca3b111 Allow last line in file to lack a line break character. 2021-07-01 23:36:09 -07:00
Perry Thompson e177b27baf Add missing import 2021-07-02 12:10:15 +09:00
Nathan Vegdahl 230248bbc3 Fix a couple additional `unused` warnings after merge. 2021-07-01 19:40:37 -07:00
Nathan Vegdahl 2224a1527e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 2021-07-01 19:37:28 -07:00
Nathan Vegdahl 9f62ad0715 Fixed last `unused` warning. 2021-07-01 19:06:52 -07:00
Nathan Vegdahl c389f41f14 Fix one of the two remaining warnings.
One of them was a lot more obvious than I thought.
2021-07-01 19:06:52 -07:00
Nathan Vegdahl 220bc85821 Fix all remaining warnings in helix-core except for two.
I'm not sure how to address them, because they look like they
might be bugs, and code is involved.  Will poke the relevant people.
2021-07-01 19:06:52 -07:00
Nathan Vegdahl b571f28641 Remove #[allow(unused)] from helix-core, and fix unused imports.
Still a bunch more warnings to fix in core, but it's a start.
2021-07-01 19:06:52 -07:00
Nathan Vegdahl e725957704 Ensure a minimum selection width on commands that need it. 2021-07-01 14:22:28 -07:00
Nathan Vegdahl 7c7be6d583 Make `Selection`'s normalize and transform methods self-consuming only. 2021-07-01 14:22:28 -07:00
Nathan Vegdahl 0ae522f3df Clean up `Selection` to not use so many allocations. 2021-07-01 14:22:28 -07:00
Nathan Vegdahl 77a266e818 Better validation method APIs for `Range`.
This way they do less work, are more specific to what we actually
need, and they compose.
2021-07-01 14:22:28 -07:00
Nathan Vegdahl d07074740b Add `Range` methods for various kinds of validation. 2021-07-01 14:22:28 -07:00
Nathan Vegdahl c1b0a71975 Change the `Range` type and associated functions to gap indexing. 2021-07-01 14:22:28 -07:00
Blaž Hrastnik 3007478567 fix: Correctly merge multiple selection ranges together
Fixes #391
2021-06-30 16:08:41 +09:00
PabloMansanet de8745aea7 Incorporate long word commands into keymap 2021-06-30 00:56:19 +09:00
PabloMansanet 73572b7780 Add long word unit tests 2021-06-30 00:56:19 +09:00
PabloMansanet 073517a92f Add long word motion implementation 2021-06-30 00:56:19 +09:00
Blaž Hrastnik 51162ae6b2 fix ca98210d20 2021-06-28 18:05:20 +09:00
Blaž Hrastnik ca98210d20 fix: insert() | delete() would calculate the new insert incorrectly
Refs #386
2021-06-28 17:49:34 +09:00
Blaž Hrastnik d4e1ec339e Don't crash if diagnostics span past EOF 2021-06-28 14:50:35 +09:00
Blaž Hrastnik 1b102d5532 Extract the merge "operator" into helix-core 2021-06-27 23:28:22 +09:00
Blaž Hrastnik 44566ea812 Release 0.3.0 2021-06-27 13:27:47 +09:00
Nathan Vegdahl a6cadddef4 Fix silly mistake in previous phantom line bug fix.
Fixes #381.  I was trying to change an index value that... wasn't
even an index value.
2021-06-26 14:26:18 +09:00
Nathan Vegdahl 2dba228c76 Fix highlight code splitting graphemes.
This resulted in phantom blank lines in files with CRLF line
endings, but could potentially have manifested with other
graphemes as well.
2021-06-26 11:09:50 +09: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
Nathan Vegdahl 9cbf564d08 Handle erroneously ignored case in RopeGraphemes iterator. 2021-06-24 10:04:03 +09:00
Blaž Hrastnik 7f6265ecf3 fix: crash with ctrl-c on empty file 2021-06-24 01:38:02 +09:00
Shafkath Shuhan fd98e743e8 Handle non-UTF8 files 2021-06-23 15:40:27 +09:00
Nathan Vegdahl 38bf9c2576 Missed some items in the CRLF PR. 2021-06-23 12:43:09 +09:00
Blaž Hrastnik 9c53461429 fix: Select matching at the start of the doc could crash. Fixes #346 2021-06-23 12:27:38 +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
Nathan Vegdahl f2954fa153 Flesh out the line ending utility unit tests. 2021-06-21 12:56:42 -07:00
Nathan Vegdahl 7c4fa18764 Fix clippy warnings. 2021-06-21 12:02:44 -07:00
Nathan Vegdahl 07e28802f6 Add function to get the line ending of a str slice.
This is needed in some places.
2021-06-21 10:29:29 -07:00
Nathan Vegdahl 3d3149e0d5 Silence clippy warning. 2021-06-20 16:13:59 -07:00
Nathan Vegdahl e686c3e462 Merge branch 'master' of github.com:helix-editor/helix into line_ending_detection
Rebasing was making me manually fix conflicts on every commit, so
merging instead.
2021-06-20 16:09:14 -07:00
Nathan Vegdahl 4efd6713c5 Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
2021-06-20 15:33:02 -07:00