terrortylor / nvim-comment

A comment toggler for Neovim, written in Lua
MIT License
479 stars 23 forks source link

[feature error] commenting on a block of C which already has comments messes up the comments #25

Open qvieth opened 3 years ago

qvieth commented 3 years ago

aa

terrortylor commented 3 years ago

Hi, you'll probably want to take a look at these two config values: (see readme for details on their purpose)

If you are still having issues can you provide details on how to replicate, with example file and key presses?

qvieth commented 3 years ago

https://user-images.githubusercontent.com/71810726/126794039-7a15776f-d9ce-426f-9a76-c7bec9851f3e.mp4

@terrortylor Tried you config, but the issue still happens

Also in this video I have to type gc 3 times before the actual comment show up(nothing happens at the first gc and second gc)(should i open another issues for this?)

Here's the block of code I tried to comment :

#include <stdio.h> 
#include <string.h>
/* a function power(m,n) to raise an integer m to a positive integer power n */
int main(int argc, char *argv[]) {
  char *a = "hello, how are you, i miss you alot";
  printf("%s", a);
}

after commenting :

/* #include <stdio.h>  */
/* #include <string.h> */
/* /* a function power(m,n) to raise an integer m to a positive integer power n */ */  <-- THIS */ BREAK THE CODE (gcc throws error when compiling the file)
/* int main(int argc, char *argv[]) { */
/*   char *a = "hello, how are you, i miss you alot"; */
/*   printf("%s", a); */
/* } */

expected behavior -> like tpope/vim-commentary 's behavior :

/* #include <stdio.h>  */
/* #include <string.h> */
/*  /1* a function power(m,n) to raise an integer m to a positive integer power n  *1/ */ <- The *1/ makes the C code not being broken
/* int main(int argc, char *argv[]) { */
/*   char *a = "hello, how are you, i miss you alot"; */
/*   printf("%s", a); */
/* } */
qvieth commented 3 years ago

Also in this video I have to type gc 3 times before the actual comment show up(nothing happens at the first gc and second gc)(should i open another issues for this?)

@terrortylor changed my timeoutlen to 500 fix the "typing gcc or gc don't work” issue above(the video above has my timeoutlen=200, I think that mess up with the typing somehow idk)

terrortylor commented 3 years ago

Thanks for the update.

I can replicate... I wasn't planning on doing nested comments... but this would annoy me. Bit strapped for time atm, but I'll have a think and see what I can do.