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

Commenting code and then beautifying removes line breaks #1440

Closed
paulheising opened this issue Jul 6, 2018 · 1 comment
Closed

Commenting code and then beautifying removes line breaks #1440

paulheising opened this issue Jul 6, 2018 · 1 comment

Comments

@paulheising
Copy link

Description

I use beautify via the VSCode extension and, at least in scss files (did not try for other types yet), it removes line breaks before commented rules. Sometimes, I just want to comment a few lines, save it (I have format on save turned on), see the result on the web page and then go on. But this behaviour is quite annoying for this scenario

Input

The code looked like this before beautification. Notice that the height property is commented, because I quickly wanted to see the result without it.

        #search-text {
            width: 43%;
            max-width: 270px;
            // height: 100%;
            border: none;
            border-radius: 5px;
            padding-left: 0.5rem;
            font-size: 1.1rem;
            color: $main-color;
        }

Expected Output

Should leave it as it is

Actual Output

The code actually looked like this after beautification. Notice that the line break before the comment has been removed. This might be wished in some cases, but I think in most cases, this is not desired, because when you start a comment in a newline, you normally do so by intention. You don't want to move that comment up on the previous line, next to the code.

        #search-text {
            width: 43%;
            max-width: 270px; // height: 100%;
            border: none;
            border-radius: 5px;
            padding-left: 0.5rem;
            font-size: 1.1rem;
            color: $main-color;
        }

Steps to Reproduce

Just beautify the code (scss file) provided above. Perhaps it also occurs for other file types, not sure, did not try.

Environment

OS: Kubuntu
IDE: Visual Studio Code

Settings

{
    "indent_size": 4,
    "end_with_newline": true,
    "wrap_line_length": 120,
    "preserve_newlines": true,
    "max_preserve_newlines": 3
}
@bitwiseman
Copy link
Member

bitwiseman commented Jul 6, 2018

Fixed in 1.8.0-rc2.

@bitwiseman bitwiseman added this to the v1.8.0 milestone Jul 6, 2018
bitwiseman added a commit to bitwiseman/js-beautify that referenced this issue Jul 6, 2018
@bitwiseman bitwiseman modified the milestones: v1.8.0-rc2, 1.8.0 Aug 22, 2018
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