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

Fix comment sorting location #1038

Merged
merged 1 commit into from Mar 20, 2017
Merged

Fix comment sorting location #1038

merged 1 commit into from Mar 20, 2017

Conversation

vjeux
Copy link
Contributor

@vjeux vjeux commented Mar 19, 2017

Right now it's only doing one test for begin/end, but in the issue #1037, we have two nodes that have the same start but different end. The current implementation incorrectly sorts them and the identifier ends up being before the container and therefore the comment search doesn't recurse into it.

Fixes #1037
Fixes #938

Right now it's only doing one test for begin/end, but in the issue prettier#1037, we have two nodes that have the same start but different end. The current implementation incorrectly sorts them and the identifier ends up being before the container and therefore the comment search doesn't recurse into it.

Fixes prettier#1037
@@ -13,8 +13,7 @@ const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;

let {
//comment
a = b
a = b //comment
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was

let {a //comment
= b} = c

so both before and after are okay.

declare module bar {
// TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input is

// This file triggers a violation of the "disjoint-or-nested ranges invariant"
// that we implicitly assume in type-at-pos and coverage implementations. In
// particular, when unchecked it causes a crash with coverage --color.

declare module foo {
}

declare module bar {
}

// TODO

so while not perfect, the new behavior is much better.

}
/**

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow parser has completely busted parsing location for this one. It happened to do the right thing in the previous version by chance.

screen shot 2017-03-18 at 5 59 27 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, have you filed a bug with Flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, internally.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type Foo = {
method(
arg: number, // I belong with baz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it doesn't inline the method anymore!

@jlongster
Copy link
Member

Very nice catch! I'll approve and let you merge in case you want to do anything else

@vjeux vjeux merged commit 5539663 into prettier:master Mar 20, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants