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

[nimpretty] Additional new line is added with each format #9144

Closed
ghost opened this issue Oct 1, 2018 · 3 comments
Closed

[nimpretty] Additional new line is added with each format #9144

ghost opened this issue Oct 1, 2018 · 3 comments
Labels

Comments

@ghost
Copy link

@ghost ghost commented Oct 1, 2018

The following code (note the new line prefix) gets an additional new line for each time formatting it again:


var x: int = 2

echo x

Related: #8078 (comment)

@ghost ghost changed the title [nimsuggest] unnecessary new line is added in front [nimpretty] unnecessary new line is added in front Oct 1, 2018
@ghost ghost changed the title [nimpretty] unnecessary new line is added in front [nimpretty] Additional new line is added with each format Oct 2, 2018
@technicallyagd
Copy link
Contributor

@technicallyagd technicallyagd commented Oct 5, 2018

Can confirm. I am also experiencing this, but only if the top line is empty or commented with only one # character. For example,

# This is a comment
var x: int = 2

echo x

will insert new line after the comment. However,

## This is also a comment
var x: int = 2

echo x

will not.

@technicallyagd
Copy link
Contributor

@technicallyagd technicallyagd commented Oct 17, 2018

@Araq, I think 778e4d1 only fixes the cases where the first few lines are completely empty. If you put comment up there, new lines will still be added in peculiar ways. For example,

# Comment to mess things up
var x: int = 2

echo x

will become

# Comment to mess things up

var x: int = 2

echo x

on the first format. Then the next one will become:

# Comment to mess things up


var x: int = 2

echo x

Then the next one:

# Comment to mess things up



var x: int = 2

echo x

This alternating pattern then goes on perpetually.

@ghost
Copy link
Author

@ghost ghost commented Oct 19, 2018

Yes, can confirm that only the first problem is fixed.

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018
narimiran added a commit to narimiran/Nim that referenced this issue Nov 1, 2018
narimiran added a commit that referenced this issue Nov 1, 2018
narimiran added a commit that referenced this issue Nov 1, 2018
(cherry picked from commit 778e4d1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants