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

Range formatting doesn't work #16140

Open
cryptomilk opened this issue Mar 7, 2024 · 0 comments
Open

Range formatting doesn't work #16140

cryptomilk opened this issue Mar 7, 2024 · 0 comments
Labels
area:ranges Issues about formatting/ignoring/etc segments of files status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug type:bug Issues identifying ugly output, or a defect in the program

Comments

@cryptomilk
Copy link

Prettier 3.2.5
Playground link

--parser babel
--tab-width 4
--range-start 598
--range-end 678

Input:

module.exports = grammar({
    name: 'rpmspec',

    rules: {
        name: ($) =>
            choice('AutoProv', 'AutoReq', 'AutoReqProv', 'AutoRequires', 'BuildArch', 'BuildArchitectures', 'BuildConflicts', 'BuildPreReq', 'BuildRequires', 'BuildRoot', 'Conflicts', 'Distribution', 'Enhances', 'Epoch', 'ExcludeArch', 'ExclusiveArch', 'ExclusiveOS', 'Group', 'License', 'Name', 'Obsoletes', 'Packager', 'Prereq', 'Provides', 'Recommends', 'Release', 'Requires', 'Suggests', 'Summary', 'Supplements', 'URL', 'Url', 'Vendor', 'Version', /Patch\d*/, /Source\d*/),

        _value: ($) =>
            repeat(choice( $.simple_expansion, $.expansion, $.integer, $.float, $.string )),
    },
});

Output:

module.exports = grammar({
    name: "rpmspec",

    rules: {
        name: ($) =>
            choice(
                "AutoProv",
                "AutoReq",
                "AutoReqProv",
                "AutoRequires",
                "BuildArch",
                "BuildArchitectures",
                "BuildConflicts",
                "BuildPreReq",
                "BuildRequires",
                "BuildRoot",
                "Conflicts",
                "Distribution",
                "Enhances",
                "Epoch",
                "ExcludeArch",
                "ExclusiveArch",
                "ExclusiveOS",
                "Group",
                "License",
                "Name",
                "Obsoletes",
                "Packager",
                "Prereq",
                "Provides",
                "Recommends",
                "Release",
                "Requires",
                "Suggests",
                "Summary",
                "Supplements",
                "URL",
                "Url",
                "Vendor",
                "Version",
                /Patch\d*/,
                /Source\d*/,
            ),

        _value: ($) =>
            repeat(
                choice(
                    $.simple_expansion,
                    $.expansion,
                    $.integer,
                    $.float,
                    $.string,
                ),
            ),
    },
});

Expected output:

module.exports = grammar({
    name: 'rpmspec',

    rules: {
        name: ($) =>
            choice('AutoProv', 'AutoReq', 'AutoReqProv', 'AutoRequires', 'BuildArch', 'BuildArchitectures', 'BuildConflicts', 'BuildPreReq', 'BuildRequires', 'BuildRoot', 'Conflicts', 'Distribution', 'Enhances', 'Epoch', 'ExcludeArch', 'ExclusiveArch', 'ExclusiveOS', 'Group', 'License', 'Name', 'Obsoletes', 'Packager', 'Prereq', 'Provides', 'Recommends', 'Release', 'Requires', 'Suggests', 'Summary', 'Supplements', 'URL', 'Url', 'Vendor', 'Version', /Patch\d*/, /Source\d*/),

        _value: ($) =>
            repeat(
                choice(
                    $.simple_expansion,
                    $.expansion,
                    $.integer,
                    $.float,
                    $.string,
                ),
            ),
    },
});

Why?
As I select a range for formatting, only the given range should be formatted, but instead it formats the complete file.

@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program area:ranges Issues about formatting/ignoring/etc segments of files status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:ranges Issues about formatting/ignoring/etc segments of files status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants