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

Format changes every save #13

Closed
Dulanic opened this issue Apr 19, 2021 · 10 comments
Closed

Format changes every save #13

Dulanic opened this issue Apr 19, 2021 · 10 comments
Labels
🐛 type/bug Describes or resolves a bug (unintended behavior or problem)

Comments

@Dulanic
Copy link

Dulanic commented Apr 19, 2021

System Information

  • Operating System: Mix, VS code in Windows, connected via SSH to linux.
  • Extension Version: 0.1.1
  • VSCode Version: 1.55.2
  • caddy Version: v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=

Describe the bug
Every time I save/format the indenting flips from what it was before. see this, all I was doing is ctrl+s.

https://streamable.com/ouziak

Steps to Reproduce
Steps to reproduce the behavior:

  1. Format thje same Caddyfile twice.

Expected Behavior
The format stays the same.

Screenshots
See above link.

Additional Context
Caddyfile /w limited section causing it:


{
	default_sni dulanic.com
	acme_ca https://acme-v02.api.letsencrypt.org/directory
	email {$ACMEEMAIL}
	#debug
}
(proxyheaders) {
	flush_interval -1
	header_up X-Real-IP {http.request.header.CF-Connecting-IP}
	header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
	header_up X-Forwarded-Host {hostport}
}

@Dulanic Dulanic added the 🐛 type/bug Describes or resolves a bug (unintended behavior or problem) label Apr 19, 2021
@matthewpi
Copy link
Member

The formatting functionality is provided by the caddy executable through the use of the fmt command.

Formatting works perfectly fine with v2.2.0 h1:sMUFqTbVIRlmA8NkFnNt9l7s0e+0gw+7GPIrhty905A=, however it breaks with v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=.

Working versions:

  • v2.2.0 h1:sMUFqTbVIRlmA8NkFnNt9l7s0e+0gw+7GPIrhty905A=
  • v2.2.1 h1:Q62GWHMtztnvyRU+KPOpw6fNfeCD3SkwH7SfT1Tgt2c=

Broken versions:

  • v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
  • v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=
  • v2.4.0-rc.1 h1:tZl6bDhlwtRwuWpebRUYpDJPhJaGyrXIMp7fmuMXwMc=

@francislavoie
Copy link
Member

What's broken about it?

@matthewpi
Copy link
Member

What's broken about it?

https://streamable.com/ouziak

After some testing caddyserver/caddy@635f075 seems to be the culprit which makes sense after looking at the tests that were added.

@francislavoie
Copy link
Member

FYI @mholt, we should probably fix that before v2.4.0, shouldn't be difficult. ☝️

@matthewpi
Copy link
Member

FYI @mholt, we should probably fix that before v2.4.0, shouldn't be difficult. ☝️

Want me to open an issue on the caddy repository? I could also work on a PR if wanted.

@francislavoie
Copy link
Member

A PR would be great ❤️ we're planning to tag v2.4.0 probably today so sooner the better! 😁

@francislavoie
Copy link
Member

francislavoie commented May 10, 2021

Oh, the problem is with the env var actually, not the comment... or rather the combination of the two.

@matthewpi
Copy link
Member

Oh, the problem is with the env var actually, not the comment... or rather the combination of the two.

Yeah, that's what I am trying to figure out right now. Without the comment it works fine but with both the environment variable and comment it messes up the rest of the file.

matthewpi added a commit to matthewpi/caddy that referenced this issue May 10, 2021
This is an extremely weird edge-case where if you had a environment variable {}
on one line, a comment on the nest line, and the closing of the block on the
following line; the rest of the Caddyfile would be indented further than it
should've been.

ref; caddyserver/vscode-caddyfile#13
matthewpi added a commit to matthewpi/caddy that referenced this issue May 10, 2021
This is an extremely weird edge-case where if you had a environment variable {}
on one line, a comment on the next line, and the closing of the block on the
following line; the rest of the Caddyfile would be indented further than it
should've been.

ref; caddyserver/vscode-caddyfile#13
mholt pushed a commit to caddyserver/caddy that referenced this issue May 10, 2021
* caddyfile(formatter): fix nesting not decrementing

This is an extremely weird edge-case where if you had a environment variable {}
on one line, a comment on the next line, and the closing of the block on the
following line; the rest of the Caddyfile would be indented further than it
should've been.

ref; caddyserver/vscode-caddyfile#13

* run gofmt

* fmt: better way of handling edge case
@matthewpi
Copy link
Member

This should be resolved by caddy v2.4.0 (once it releases).

@mholt
Copy link
Member

mholt commented May 10, 2021

Releasing now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 type/bug Describes or resolves a bug (unintended behavior or problem)
Projects
None yet
Development

No branches or pull requests

4 participants