Commit Graph

24 Commits (168b11e09150cf1d9cef70cfc32ff173f72bd1b9)

Author SHA1 Message Date
Kieran Moy e670970dd8
Change default comment token to # for unrecognized files (#12080)
* Change the default comment token

* update test

* keep the original
2024-12-05 01:11:39 +01:00
Michael Davis 191b0f08a9
Remove unnecessary clippy allow for old false positive
The clippy version after the recent MSRV bump no longer emits
`redundant_clone` warnings for these lines. We allowed these previously
since they were emitted as false positives.
2024-12-02 09:23:42 -05:00
TornaxO7 be2884d800
Continue line comments (#10996) 2024-10-19 05:48:07 -04:00
Gabriel Dinner-David 26b3dc29be
toggling of block comments (#4718) 2024-02-27 22:36:25 +09:00
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
2023-02-12 13:13:22 -06:00
Pascal Kuthe 8a3ec443f1
Fix new clippy lints (#5892) 2023-02-09 16:27:08 -06:00
Blaž Hrastnik c94feed83d
core: Move state into the history module 2022-11-08 21:03:54 +09:00
Danilo Spinella 6b80cb8a77
Fix toggle_comments command on multiple selections (#1882) 2022-04-05 10:01:58 +09:00
Blaž Hrastnik f979bdc442 Specify capacity on toggle_line_comments 2021-11-06 23:57:42 +09:00
Kirawi 92c2d5d3bf
Document more of helix-core (#904) 2021-10-26 01:02:16 +09:00
Nathan Vegdahl 3fda350494 Fixes for new clippy lints in Rust 1.54. 2021-07-29 22:47:18 +02:00
Nathan Vegdahl f62ec6e51e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 2021-07-26 11:19:10 -07:00
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`
2021-07-26 11:00:58 +09:00
Nathan Vegdahl c9300ec35f Fix comment toggle command also sometimes toggling the next line. 2021-07-20 12:23:40 -07:00
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>
2021-07-19 01:33:38 +09:00
Blaž Hrastnik 7f6265ecf3 fix: crash with ctrl-c on empty file 2021-06-24 01:38:02 +09:00
Wojciech Kępka c978d811d9 Cleanup find_first_non_whitespace_char funcs 2021-06-08 17:22:37 +09:00
Blaž Hrastnik 9eaef6e333 Fully drop State references. 2021-03-31 15:45:18 +09:00
Blaž Hrastnik 06aca7691c clippy lint 2021-03-24 14:58:01 +09:00
Blaž Hrastnik f29f01858d Implement iter() and len() directly on Selection. 2021-03-19 11:14:13 +09:00
Blaž Hrastnik 59e6024186 Remove State from a few more signatures. 2021-03-18 14:17:32 +09:00
Blaž Hrastnik 8eaf9a432d Make Transaction::change only rely on the rope. 2021-03-18 13:39:56 +09:00
Blaž Hrastnik 7a1ff5e45f commands: Wire up toggle comments as ctrl-c 2021-02-19 13:59:24 +09:00
Blaž Hrastnik d0791e0f98 core: Implement comment toggling module. 2021-02-18 18:35:39 +09:00