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

cue fmt --simplify removes ellipsis comments #3198

Closed
NoamTD opened this issue Jun 4, 2024 · 0 comments
Closed

cue fmt --simplify removes ellipsis comments #3198

NoamTD opened this issue Jun 4, 2024 · 0 comments
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@NoamTD
Copy link
Contributor

NoamTD commented Jun 4, 2024

What version of CUE are you using (cue version)?

$ cue version
cue version v0.0.0-20240604142238-b6278c4683a2

go version go1.22.3
      -buildmode exe
       -compiler gc
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS darwin
             vcs git
    vcs.revision b6278c4683a28a8d7020695441b439ab80e8b06a
        vcs.time 2024-06-04T14:22:38Z
    vcs.modified true
cue.lang.version v0.9.0

Does this issue reproduce with the latest stable release?

yes

What did you do?

I ran the below test:

# store original cue file as backup
cp test.cue test.cue.golden

exec cue fmt --simplify test.cue
cmp test.cue test.cue.golden

-- test.cue --
// a comment
...
// another comment

What did you expect to see?

a passing test

What did you see instead?

a failing test:

# store original cue file as backup (0.060s)
> cp test.cue test.cue.golden
> exec cue fmt --simplify test.cue
> cmp test.cue test.cue.golden
diff test.cue test.cue.golden
--- test.cue
+++ test.cue.golden
@@ -1,1 +1,3 @@
+// a comment
 ...
+// another comment

FAIL: /var/folders/xj/q6k0bchn5414yzgryc_m1hgw0000gn/T/testscript4089464374/repr.txtar/script.txtar:5: test.cue and test.cue.golden differ
error running repr.txtar in /var/folders/xj/q6k0bchn5414yzgryc_m1hgw0000gn/T/testscript4089464374/repr.txtar
@NoamTD NoamTD added NeedsInvestigation Triage Requires triage/attention labels Jun 4, 2024
@NoamTD NoamTD changed the title cue fmt --simplify removes comment above elipsis cue fmt --simplify removes ellipsis comments Jun 4, 2024
cueckoo pushed a commit that referenced this issue Jun 6, 2024
Whe simplification is enabled, the current implementation prints a
"dummy" ellipsis during formatting, instead of the original ellipsis.
This means that comments associated with the original ellipsis are not
printed in the formatted CUE.
To fix this, we associate the original comments with the dummy ellipsis
so they won't get lost.

Fixes #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: Ibebbd97ac768de7a2c0d9855c9ec6c7a497435c8
cueckoo pushed a commit that referenced this issue Jun 7, 2024
This adds some tests for handling of comments associated with ellipseses
when running `cue fmt -s`.

Updates #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: I24d8adaadcfe2d14b3231ac057252d582f0b9624
cueckoo pushed a commit that referenced this issue Jun 7, 2024
Whe simplification is enabled, the current implementation prints a
"dummy" ellipsis during formatting, instead of the original ellipsis.
This means that comments associated with the original ellipsis are not
printed in the formatted CUE.
To fix this, we associate the original comments with the dummy ellipsis
so they won't get lost.

Fixes #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: I276e573db8d7b4e6b69db25a164be7211378d486
cueckoo pushed a commit that referenced this issue Jun 7, 2024
Whe simplification is enabled, the current implementation prints a
"dummy" ellipsis during formatting, instead of the original ellipsis.
This means that comments associated with the original ellipsis are not
printed in the formatted CUE.
To fix this, we associate the original comments with the dummy ellipsis
so they won't get lost.

Fixes #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: Ibebbd97ac768de7a2c0d9855c9ec6c7a497435c8
cueckoo pushed a commit that referenced this issue Jun 7, 2024
When simplification is enabled, the current implementation prints a
"dummy" ellipsis during formatting, instead of the original ellipsis.
This means that comments associated with the original ellipsis are not
printed in the formatted CUE.
To fix this, we associate the original comments with the dummy ellipsis
so they won't get lost.

Fixes #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: Ibebbd97ac768de7a2c0d9855c9ec6c7a497435c8
cueckoo pushed a commit that referenced this issue Jun 7, 2024
This adds some tests for handling of comments associated with ellipseses
when running `cue fmt -s`.

Updates #3198.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: I24d8adaadcfe2d14b3231ac057252d582f0b9624
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195919
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
@cueckoo cueckoo closed this as completed in 9bd3e17 Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

1 participant