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

indent_char for css doesn't work #266

Closed
dstudzinski opened this issue Apr 1, 2015 · 10 comments
Closed

indent_char for css doesn't work #266

dstudzinski opened this issue Apr 1, 2015 · 10 comments

Comments

@dstudzinski
Copy link

I can't get indent_char working for scss/css file.
My config file works with SublimeText3 but it stops with Atom.
Instead of hard tab I always have space.

Atom Beautify - Debugging information

The following debugging information was generated by Atom Beautify on Wed Apr 01 2015 13:32:51 GMT+0200 (Środkowoeuropejski czas letni).


Platform: win32

Versions

Atom Version: 0.188.0

Atom Beautify Version: 0.23.1

Original file to be beautified

Original File Path: C:\Users\***\Documents\AngularProjects\timesheet-core\app\src\core\directives\menu\test.scss

Original File Grammar: SCSS

Original File Contents:

body {
 background: red;
}
h1 {
 font-size: 16px;
}

Beautification options

Editor Options:
Options from Atom Editor settings

{
    "indent_size": 1,
    "indent_char": "\t",
    "indent_with_tabs": true
}

Config Options:
Options from Atom Beautify package settings

{
    "css": {
        "selector_separator_newline": true,
        "indent_size": 1,
        "indent_char": "\t",
        "newline_between_rules": false,
        "preserve_newlines": false
    },
    "js": {
        "indent_size": 1,
        "indent_char": "\t",
        "indent_level": 0,
        "indent_with_tabs": true,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "space_in_paren": false,
        "jslint_happy": false,
        "space_after_anon_function": false,
        "brace_style": "collapse",
        "break_chained_methods": false,
        "keep_array_indentation": false,
        "keep_function_indentation": false,
        "space_before_conditional": true,
        "eval_code": false,
        "unescape_strings": false,
        "wrap_line_length": 0,
        "end_with_newline": false
    },
    "html": {
        "htmlbeautifier_path": "",
        "indent_inner_html": false,
        "indent_size": 1,
        "indent_char": "\t",
        "brace_style": "collapse",
        "indent_scripts": "normal",
        "wrap_line_length": 250,
        "wrap_attributes": "auto",
        "wrap_attributes_indent_size": 1,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "unformatted": [
            "a",
            "sub",
            "sup",
            "b",
            "i",
            "u"
        ],
        "end_with_newline": false
    },
    "sql": {
        "indent_size": 1,
        "keywords": "upper",
        "identifiers": "lower",
        "sqlformat_path": ""
    },
    "markdown": {
        "pandoc_path": "",
        "yaml_front_matter": true
    },
    "perl": {
        "perltidy_path": "perltidy",
        "perltidy_profile": ""
    },
    "php": {
        "cs_fixer_path": "",
        "fixers": "",
        "level": ""
    },
    "python": {
        "autopep8_path": "",
        "max_line_length": 79,
        "indent_size": 1,
        "ignore": [
            "E24"
        ]
    },
    "ruby": {
        "rbeautify_path": ""
    },
    "c": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "cpp": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "objectivec": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "cs": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "d": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "java": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "pawn": {
        "uncrustifyPath": "",
        "configPath": ""
    },
    "vala": {
        "uncrustifyPath": "",
        "configPath": ""
    }
}

Home Options:
Options from C:\Users\***\.jsbeautifyrc

{}

EditorConfig Options:
Options from EditorConfig file

{}

Project Options:
Options from .jsbeautifyrc files starting from directory C:\Users\***\Documents\AngularProjects\timesheet-core\app\src\core\directives\menu and going up to root

[
    {},
    {},
    {},
    {},
    {},
    {
        "html": {
            "allowed_file_extensions": [
                "htm",
                "html",
                "xhtml",
                "shtml",
                "xml",
                "svg"
            ],
            "brace_style": "collapse",
            "end_with_newline": false,
            "indent_char": "\t",
            "indent_handlebars": false,
            "indent_inner_html": false,
            "indent_scripts": "keep",
            "indent_size": 1,
            "max_preserve_newlines": 0,
            "preserve_newlines": true,
            "unformatted": [
                "a",
                "span",
                "img",
                "code",
                "pre",
                "sub",
                "sup",
                "em",
                "strong",
                "b",
                "i",
                "u",
                "strike",
                "big",
                "small",
                "pre",
                "h1",
                "h2",
                "h3",
                "h4",
                "h5",
                "h6"
            ],
            "wrap_line_length": 120
        },
        "css": {
            "allowed_file_extensions": [
                "css",
                "scss",
                "sass",
                "less"
            ],
            "end_with_newline": false,
            "indent_char": "\t",
            "indent_size": 1,
            "newline_between_rules": true,
            "selector_separator": " ",
            "selector_separator_newline": true
        },
        "js": {
            "allowed_file_extensions": [
                "js",
                "json",
                "jshintrc",
                "jsbeautifyrc"
            ],
            "brace_style": "collapse",
            "break_chained_methods": false,
            "e4x": false,
            "end_with_newline": false,
            "indent_char": "\t",
            "indent_level": 0,
            "indent_size": 1,
            "indent_with_tabs": false,
            "jslint_happy": false,
            "keep_array_indentation": false,
            "keep_function_indentation": false,
            "max_preserve_newlines": 0,
            "preserve_newlines": true,
            "space_after_anon_function": false,
            "space_before_conditional": true,
            "space_in_empty_paren": false,
            "space_in_paren": false,
            "unescape_strings": false,
            "wrap_line_length": 120
        }
    },
    {},
    {},
    {},
    {}
]

Logs

Error logs: Not yet supported

@imperez
Copy link

imperez commented Apr 6, 2015

I'm having the same issue with a SQL file.

@Glavin001
Copy link
Owner

Looks like indent_char is actually indent_character in Atom Beautify's wrapper of @prettydiff. See https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/css-prettydiff-beautify.coffee#L8

This may be a bug on my part, I will have to get to later, after my exams. For now, try setting indent_character instead of indent_char (or in addition to).


@imperez I am not sure that SQL beautification currently supports indent_char at all. See https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/sql-beautify.coffee for the beautifier's source code.
It uses https://github.com/andialbrecht/sqlparse
There may be some unsupported arguments in Atom Beautify that sqlparse does support: see their documentation at https://sqlparse.readthedocs.org/en/latest/api/#formatting-of-sql-statements
However I do not see character indentation in the sqlparse docs. I do see an indent_tabs argument that will force tabs instead of spaces. This currently is not supported by Atom Beautify but definitely could be later.
Feel free to make a pull request for Atom Beautify by editing the file at https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/sql-beautify.coffee and adding support.
Also please make a separate issue for SQL beautification and we can discuss on a separate thread and hopefully close that issue once I am finished my exams.

Thanks!

@Glavin001 Glavin001 added the bug label Apr 6, 2015
@Glavin001 Glavin001 added this to the v1.0.0 milestone Apr 6, 2015
@Glavin001 Glavin001 self-assigned this Apr 6, 2015
@prettydiff
Copy link
Collaborator

Pretty Diff uses the inchar property for this.

http://prettydiff.com/documentation.php#inchar

@Glavin001
Copy link
Owner

js-beautify uses the key indent_char ( https://github.com/beautify-web/js-beautify#options ). I think Atom Beautify should standardize option key to indent_char (instead of indent_character).

In summary of all of the above: this is an Atom Beautify bug. I must have mistakenly thought indent_character was the key where it should have been indent_char. See

inchar: options.indent_character

@dstudzinski
Copy link
Author

using "indent_character" option name instead of "indent_char" solved my problem so it's a bug

@Glavin001
Copy link
Owner

Published patch to v0.23.4

Let me know if it all works now.

@dstudzinski
Copy link
Author

It works only with css. It's still bug in scss files. When I add "indent_character": "\t" option scss files work.

@Glavin001
Copy link
Owner

When I add "indent_character": "\t" option scss files work.

This does not make sense: the SCSS/LESS beautifier (wrapping Prettydiff) is now not using indent_character at all (see fad9597 ).

Can you try to reload Atom? Atom Menu -> View -> Reload

@dstudzinski
Copy link
Author

Ok after closing atom, reboot (I'm usually only suspend my pc) it works now for css and scss files. I don't know why it worked only for css before.

@Glavin001
Copy link
Owner

It only worked for CSS before because CSS is handled by js-beautify which does support indent_char option. SCSS is handled by Prettydiff, which also supports indentation character, however I made the mistake of naming the option indent_character instead of indent_char. It has been renamed/fixed with v0.23.4 patch.

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

4 participants