[WIP] Feature: Comment toggling#188
Conversation
| } | ||
| } | ||
|
|
||
| void toggle_comment_lines(linenr_T start, linenr_T end) |
There was a problem hiding this comment.
These function should probably live somewhere else. I'm not sure where though.
| int b_diff_failed; // internal diff failed for this buffer | ||
| #endif | ||
|
|
||
| char_u *b_oni_line_comment; |
There was a problem hiding this comment.
Not sure how OK it is to add a new field to the buf_T structure. But since it's at the end it should at least have a relatively low chance of impacting FFI and such.
There was a problem hiding this comment.
Thanks for calling this out. Should be safe, as we're the only consumer of the library
|
I think I might have a different version of |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| MU_TEST(test_toggle_uncommented) | ||
| { | ||
| vimInput("g"); | ||
| vimInput("c"); | ||
| vimInput("c"); | ||
|
|
||
| char_u *line = vimBufferGetLine(curbuf, vimCursorGetLine()); | ||
| printf("LINE: %s\n", line); | ||
|
|
||
| mu_check(strcmp(line, "//This is the first line of a test file") == 0); | ||
| } |
|
Hmm, that's unfortunate. I can easily reproduce. I'll have to try to make this a failing test. Interesting though that there's no error in visual mode. Although it still crashes when uncommenting. |
Right, it was strange to me, because I see a test case that exercises the un-commenting. It seems to me, based on the exception, an issue with the cursor position. We use the
It must be hitting this condition here: Line 159 in 3c9fe45 Although it's not clear to me why; as the |
Good idea. Will try that!
It's being called with |
|
I believe I've fixed both, but I'm not able to get esy to rebuild linked dependencies, so I'm unable to test it in Oni2 proper |
b29204a to
6ac48e6
Compare
|
Thanks for fixing those last issues, @glennsl ! I picked up the latest and it is working great - undo, redo, motions, macros🥇 Very excited to have this in! |
|
Woohoo! Will you do a release so I can pick it up properly in |
|
Done! Released as |

This adds a new operator,
gc/gcc, which will comment or uncomment the current or selected lines. It also adds a new function to the API,vimOptionSetLineCommentto specify the comment string that will be used for the current buffer.The way it works is a bit crude currently, but it does the job. The comment string will only be inserted (and checked) at the very beginning of each line, ignoring indentation, and lines are commented or uncommented individually rather than as a block. If I can get a decent workflow going I might come back to this to give it some more polish. But until then it's fair game if anyone else wants a go at it.