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
tim-st opened this Issue Oct 1, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@tim-st
Copy link
Contributor

tim-st 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)

@tim-st tim-st changed the title [nimsuggest] unnecessary new line is added in front [nimpretty] unnecessary new line is added in front Oct 1, 2018

@tim-st tim-st changed the title [nimpretty] unnecessary new line is added in front [nimpretty] Additional new line is added with each format Oct 2, 2018

@technicallyagd

This comment has been minimized.

Copy link
Contributor

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.

@andreaferretti andreaferretti added the Tools label Oct 8, 2018

@Araq Araq closed this in 778e4d1 Oct 16, 2018

@technicallyagd

This comment has been minimized.

Copy link
Contributor

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.

@tim-st

This comment has been minimized.

Copy link
Contributor

tim-st 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

nimpretty: fixes #9144
(cherry picked from commit 778e4d1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment