Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commenting visual block with an embedded empty comment line. #144

Open
dvogel opened this issue Apr 29, 2021 · 1 comment
Open

Commenting visual block with an embedded empty comment line. #144

dvogel opened this issue Apr 29, 2021 · 1 comment

Comments

@dvogel
Copy link

dvogel commented Apr 29, 2021

If I have an "empty" comment line inside a visual block, gc eats the space preceding %s in my commentstring (or b:commentary_format). I've captured this in a gist but, I will illustrate the before and after here.

Visually selecting this entire block and commenting (with commentstring=#\ %s):

resource aws_subnet a-subnet {
  # this line is awesome:
  cidr_block = "10.0.0.0/24"
}

Yields the properly indented block:

# resource aws_subnet a-subnet {
#   # this line is awesome:
#   cidr_block = "10.0.0.0/24"
# }

However, if I introduce an empty comment line like so:

resource aws_subnet a-subnet {
  # this is the first line of a comment
  # 
  # this line is awesome:
  cidr_block = "10.0.0.0/24"
}

Then visually selecting the entire block and commenting it yields:

#resource aws_subnet a-subnet {
#  # this is the first line of a comment
#  # 
#  # this line is awesome:
#  cidr_block = "10.0.0.0/24"
#}

This is true regardless of whether that "empty" comment line has a trailing space.

@novasenco
Copy link

novasenco commented Apr 29, 2021

I tracked down the issue to these two pull requests:

which stem from the initially contentious issue, #40

Of course, the issue is a result of this line:

let l = l[:-2]

Although, I must say it's weird that it does not happen in visual-block, and I have not fully investigated that aspect.

Maybe:

  1. b:commentary_strip_empty option (like b:commentary_startofline) or ..
  2. fix root of the problem and check if line is "equal" to just an "empty comment" or something along those lines

If you want me to try my hand at a pull req, I can. If you can spot an easy solution, then please do fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants