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

class method formatted incorrectly due to missing context(?) #15

Open
cmcaine opened this issue Apr 14, 2018 · 2 comments
Open

class method formatted incorrectly due to missing context(?) #15

cmcaine opened this issue Apr 14, 2018 · 2 comments

Comments

@cmcaine
Copy link

cmcaine commented Apr 14, 2018

diff --git a/src/keyseq.ts b/src/keyseq.ts
index 5caa81a..d5dccbc 100644
--- a/src/keyseq.ts
+++ b/src/keyseq.ts
@@ -35,12 +35,12 @@ export class MinimalKey {
 
     /** Does this key match a given MinimalKey extending object? */
     match(keyevent) {
-        // 'in' doesn't include prototypes, so it's safe for this object.
-        for (let attr in this) {
-            if (this[attr] !== keyevent[attr]) return false
-        }
-        return true
-    }
+                        // 'in' doesn't include prototypes, so it's safe for this object.
+                        for (let attr in this) {
+                            if (this[attr] !== keyevent[attr]) return false
+                        }
+                        return true
+                    }
 }

Prettier handles it correctly.

@JamesHenry
Copy link
Contributor

@cmcaine Can I please check what you mean by prettier handles it correctly?

I am guessing you mean, when you run prettier on the whole file, and not just the range?

You can now reproduce ranges issues using the prettier playground.

E.g. Here is a range I am selecting from a separate, unrelated issue:
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAgBtUAjfAMxwnXwB0RiT6BuWqNjqSKAZwIEN8AXnxkhAPnzceEQnAB0hCAHMAFCQCUrdjs6N5M9HBgALVFDVaQAGhARMMVNB7JQ-HFQDuABXcIXKPwAbhCoACY2ICQ4-GAA1sYAypix5srIMDgArnC25jxweN4xyuj8yOT8hAW2AFY8AB4AQjHxSfxGADLmcBVVNSApOAU4yFH8JACeSlCRmDjmMADq4abIABwADLbzEAVLMZhj83AjQb22OHAAjlmoV8X8peVIldW5IAXoqBnZHzxpOQARSyEHgfXethgExWYTWSAATFCYqhiBYAMLUMpjKDQC4gLIFAAqEwCbwGMQscES0LwyARSJAlOUcAAolAIkgAGybAC+vKAA

My guess is you will be able to reproduce the issue there if you apply the same range to your source that matches your git diff (i.e. what precise-commits is doing for you behind the scenes)

Please could you try and build that reproduction in the playground to confirm?

@cmcaine
Copy link
Author

cmcaine commented Aug 1, 2018

Yes, I am comparing with running the whole file through prettier.

This issue should maybe be on prettier rather than here. Depends what prettier --range-* is intended to do. Obviously in the precise-commits use this is wrong. Maybe if you just want to format some js in another document --range is fine, though what it's doing here is still pretty weird.

Reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants