caddyserver / vscode-caddyfile

Rich Caddyfile support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=matthewpi.caddyfile-support
MIT License
79 stars 3 forks source link

Comments in global options get marked as duplicate #263

Closed francislavoie closed 1 year ago

francislavoie commented 1 year ago

When there's multiple comments in a global options block, the # gets read as the global option name, and then gets marked as a duplicate. Comments here should take precedence over that rule.

image

Also, some global options can be repeated, actually, so I'm not sure that's a correct rule to have. See log which can be repeated with different logger names https://caddyserver.com/docs/caddyfile/options

matthewpi commented 1 year ago

Should I just remove the duplicate global options check? I wrote it more as a PoC with the language server rather than a proper validation rule. I can easily fix the comments, but checking if a directive is allowed to be duplicated is more challenging.

Technically the log directive itself cannot be duplicated, but if you specify a unique argument it can.

{
  log test { }
  log test2 { }
}

is valid, while

{
  log test { }
  log test { }
}

should trigger a warning.

francislavoie commented 1 year ago

I don't think it's a particularly useful check. Caddy will complain when adapting if it matters.

But I am an "expert" and I'm less likely to make that mistake anyways, so my opinion isn't from a perspective of a beginner.

I can say it isn't something we ever hear about being an issue when providing support on the Caddy community forums.

matthewpi commented 1 year ago

https://github.com/matthewpi/vscode-caddyfile-support/commit/ee91c9af970d6fea298cfd4bcf877413656f1714

francislavoie commented 1 year ago

Thanks!

Do comments count as comments now (i.e. # gets lexed before it being an "option")? That commit doesn't seem to suggest you adjusted that.

matthewpi commented 1 year ago

Ah, I just noticed that as well. I'll see what I can do before cutting a release later.

matthewpi commented 1 year ago

Do comments count as comments now (i.e. # gets lexed before it being an "option")? That commit doesn't seem to suggest you adjusted that.

Fixed by https://github.com/matthewpi/vscode-caddyfile-support/commit/d2dbe7637142124f3f3f865ee562cf8467c516ca