Atom-beautify: Over Indenting

Created on 31 Mar 2016  Â·  17Comments  Â·  Source: Glavin001/atom-beautify

Hi, I am using the default deatures, didn't touched nothing

The results of beautification are not what I expect.
instead, got this:

<div>
        <Widget txt={this.state.txt} update={this.update}/>
                <p>
                              Hello
               </p>
</div>

Expected Results

The beautified code should have looked like:

<div>
    <Widget txt={this.state.txt} update={this.update}/>
</div>

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

    Debug

Here is a link to the debug.md Gist: https://gist.github.com/...

How to create debug.md Gist

Note that this will include a copy of your code.
If your code is private, please create a different sample of code that reproduces the problem.

  1. In the Atom command-palette,
    search for and run the command Atom Beautify: Help Debug Editor.
    The debugging results will be copied to your clipboard.
  2. Create a new Gist at https://gist.github.com/
  3. Create a file in your new Gist called debug.md.
  4. Paste your debugging results from Atom beautify into debug.md file in your Gist.
  5. Add a link to your Gist in your new Issue.

Checklist

  • [x] I have tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Searched for existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [ ] Generated debugging information and added link for debug.md Gist to this issue
question

All 17 comments

It would be really helpful if you could generate the debug.md file and save it as a gist. I cannot tell which beautifier or variant of HTML grammar you are using, which makes it challenging to determine which software package could be causing this.

Please provide this in a separate Gist as not to clutter this Issue. Thank you.

Sure.
Updated earlier comment

any progress?

The problem is in your EditorConfig options under section https://gist.github.com/thehulke/753c2296fe9590bf0ca0b51fbc8358d2#beautification-options :

{
    "_default": {
        "charset": "utf-8",
        "indent_style": "tab",
        "end_of_line": "lf",
        "insert_final_newline": true,
        "trim_trailing_whitespace": true,
        "indent_size": "tab",
        "indent_char": "\t",
        "indent_with_tabs": true
    }
}

Notice the indent_size is tab.

EditorConfig does not tell _where_ it found the .editorconfig file so I recommend that you start from your desired file and move upwards until your find it. Then ensure it is correct.
There may be a problem with EditorConfig support in particular. The applicable code can be found at https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/index.coffee#L700-L725 if you are interested in debugging on your own.

Good catch. I was having trouble tracking this down. It looked like a Pretty Diff problem, but I just couldn't reproduce it.

It's not a Pretty Diff problem. Look at the final options generated and given to Pretty Diff: https://gist.github.com/thehulke/753c2296fe9590bf0ca0b51fbc8358d2#final-options

{
    "inchar": "\t",
    "insize": "tab",
    "objsort": false,
    "preserve": "all",
    "comments": "indent",
    "vertical": "none",
    "wrap": 0,
    "space": false,
    "endcomma": false,
    "methodchain": true
}

insize:"tab" is clearly wrong :stuck_out_tongue_winking_eye: . It is either EditorConfig or how Atom Beautify is dealing with EditorConfig.

I've had the same problem.
It seems, that atom-beautify is using it's own default options (since the better-settings change) and not atom's editor settings.
To solve the problem, just configure the settings for atom-beautify directly.

P.S. I'm using atom beta with neither .editorconfig nor .jslintrc

It seems, that atom-beautify is using it's own default options (since the better-settings change) and not atom's editor settings.

This is a bug. Please create an issue (including debug.md in Gist as instructed) so I can resolve it ASAP. Thank you!

I've just created an issue (see #894)

+1 on this. In HTML the same happens, I get Tab char instead of space when beautifying, however I didn't see that happening in the editor config. Here's the dump

@chenasraf : In your debug info under EditorConfig Options it has:

{
    "_default": {
        "charset": "utf-8",
        "indent_style": "tab",
        "end_of_line": "lf",
        "insert_final_newline": true,
        "trim_trailing_whitespace": true,
        "indent_size": "tab",
        "indent_char": "\t",
        "indent_with_tabs": true
    }
}

I recommend you change your indent_style from tab to resolve this issue.

I did, and it didn't change. I edited the gist, the newest revision should
show it.

On Tue, Apr 5, 2016, 19:29 Glavin Wiechert [email protected] wrote:

@chenasraf https://github.com/chenasraf : In your debug info under EditorConfig
Options it has:

{
"_default": {
"charset": "utf-8",
"indent_style": "tab",
"end_of_line": "lf",
"insert_final_newline": true,
"trim_trailing_whitespace": true,
"indent_size": "tab",
"indent_char": "\t",
"indent_with_tabs": true
}
}

I recommend you change your indent_style from tab to resolve this issue.

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/Glavin001/atom-beautify/issues/882#issuecomment-205884535

It still shows that EditorConfig options are using tabs.

I'd recommend using https://github.com/editorconfig/editorconfig-core-js#in-command-line to help find the problematic .editorconfig file.

iv'e set the .editorconfig in my project folder to

indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

and it looks great, thanks!

Awesome to hear! Let us know if you have any other questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

catscarlet picture catscarlet  Â·  3Comments

mkermani144 picture mkermani144  Â·  4Comments

bartocc picture bartocc  Â·  5Comments

philippelesaux picture philippelesaux  Â·  4Comments

misterernest picture misterernest  Â·  3Comments