Commit Graph

21 Commits (d34839781a2e9ed18fac7aae27d0a923fc68870a)

Author SHA1 Message Date
Gabriel Dinner-David 26b3dc29be
toggling of block comments (#4718) 9 months ago
Mike Trinkala ef221abe83
Prevent a panic when uncommenting a line with only a comment token (#5933)
Open a new document `test.rs` and type the following:
`di//<esc><C-c>`

The margin calculation pushes the range out of bounds for the comment
marker when there are no characters (newline) after it.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
Char range out of bounds: char range 0..3,
Rope/RopeSlice char length 2', ropey-1.6.0/src/rope.rs:546:37

The debug build catches the error in the transaction: thread 'main'
panicked at 'attempt to subtract with overflow',
helix-core/src/transaction.rs:503:26
2 years ago
Pascal Kuthe 8a3ec443f1
Fix new clippy lints (#5892) 2 years ago
Blaž Hrastnik c94feed83d
core: Move state into the history module 2 years ago
Danilo Spinella 6b80cb8a77
Fix toggle_comments command on multiple selections (#1882) 3 years ago
Blaž Hrastnik f979bdc442 Specify capacity on toggle_line_comments 3 years ago
Kirawi 92c2d5d3bf
Document more of helix-core (#904) 3 years ago
Nathan Vegdahl 3fda350494 Fixes for new clippy lints in Rust 1.54. 3 years ago
Nathan Vegdahl f62ec6e51e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Omnikar 112ae5cffe
Determine whether to use a margin of 0 or 1 when uncommenting (#476)
* Implement `margin` calculation for uncommenting

* Move `margin` calculation to `find_line_comment`

* Fix comment bug with multiple selections on a line

* Fix `find_line_comment` test for new return type

* Generate a single vec of lines for comment toggle

`toggle_line_comments` collects the lines covered by all selections into
a `Vec`, skipping duplicates. `find_line_comment` now returns the lines
to operate on, instead of returning the lines to skip.

* Fix test for `find_line_comment`

* Reserve length of `to_change` instead of `lines`

The length of `lines` includes blank lines which will be skipped, and as
such do not need space for a change reserved for them. `to_change`
includes only the lines which will be changed.

* Use `token.chars().count()` for token char length

* Create `changes` with capacity instead of reserving

* Remove unnecessary clones in `test_find_line_comment`

* Add test case for 0 margin comments

* Add comments explaining `find_line_comment`
3 years ago
Nathan Vegdahl c9300ec35f Fix comment toggle command also sometimes toggling the next line. 3 years ago
Cor Peters cd65a48635
Made toggle_comments language dependent (#463)
* Made toggle_comments language dependent

* Fixed Test Cases

* Added clippy suggestion

* Small Fixes

* Clippy Suggestion

Co-authored-by: Cor <prive@corpeters.nl>
3 years ago
Blaž Hrastnik 7f6265ecf3 fix: crash with ctrl-c on empty file 3 years ago
Wojciech Kępka c978d811d9 Cleanup find_first_non_whitespace_char funcs 4 years ago
Blaž Hrastnik 9eaef6e333 Fully drop State references. 4 years ago
Blaž Hrastnik 06aca7691c clippy lint 4 years ago
Blaž Hrastnik f29f01858d Implement iter() and len() directly on Selection. 4 years ago
Blaž Hrastnik 59e6024186 Remove State from a few more signatures. 4 years ago
Blaž Hrastnik 8eaf9a432d Make Transaction::change only rely on the rope. 4 years ago
Blaž Hrastnik 7a1ff5e45f commands: Wire up toggle comments as ctrl-c 4 years ago
Blaž Hrastnik d0791e0f98 core: Implement comment toggling module. 4 years ago