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 drags comments into import block #720

Open
cueckoo opened this issue Jul 3, 2021 · 1 comment
Open

Cue fmt drags comments into import block #720

cueckoo opened this issue Jul 3, 2021 · 1 comment
Labels
fmt Related to formatting functionality. NeedsFix NeedsInvestigation

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @ah-edg in cuelang/cue#720

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

$ cue version
cue version 0.3.0-beta.3 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

Run cue fmt on this input:

import "encoding/base64"

// comment

#A: {}

What did you expect to see?

no change

What did you see instead?

import ( "encoding/base64"

	// comment
)

#A: {}
@cueckoo cueckoo added fmt Related to formatting functionality. NeedsFix NeedsInvestigation labels Jul 3, 2021
@myitcv myitcv added this to the fmt-redesign milestone Apr 27, 2023
@myitcv myitcv added the zGarden label Jun 15, 2023
@rudifa
Copy link
Contributor

rudifa commented Nov 14, 2023

This is same as cmd/fmt: single import and comment combined #1447.

The newline after the comment triggers the bug, as the comment gets associated with the previous import line, then the comment is misplaced into the import block.

In the absence of a newline between the comment and the code following it there is no problem, and the fmt output is same as input.

@mvdan mvdan removed the zGarden label Feb 8, 2024
@mvdan mvdan removed this from the fmt-redesign milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fmt Related to formatting functionality. NeedsFix NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

4 participants