rokucommunity / brighterscript-formatter

A code formatter for BrighterScript (and BrightScript)
MIT License
14 stars 6 forks source link

negative variable #50

Closed tbrixi closed 2 years ago

tbrixi commented 2 years ago

negative variable

source code: y = -x

actual formatter result: y = - x

expected result: y = -x

brighterscript-formatter: 1.6.10 bsfmt.json: { "indentStyle": "tabs", "indentSpaceCount": 4, "formatIndent": true, "keywordCase": "lower", "typeCase": "lower", "compositeKeywords": "split", "removeTrailingWhiteSpace": true, "formatInteriorWhitespace": true, "insertSpaceBeforeFunctionParenthesis": false, "insertSpaceBetweenEmptyCurlyBraces": false, "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false, "insertSpaceBetweenAssociativeArrayLiteralKeyAndColon": false, "formatSingleLineCommentType": "original", "formatMultiLineObjectsAndArrays" : true }

TwitchBronBron commented 2 years ago

@markwpearce you recently did some work on some of this stuff, right? Do you think your other logic would be easily adapted to fix this as well?

markwpearce commented 2 years ago

It must be some weird interaction with one of those options. I'm not seeing this issue with default options.

markwpearce commented 2 years ago

@tbrixi What version of the formatter are you using? Negative variables formatting was updated in 1.16.6

markwpearce commented 2 years ago

Just investingated with latest version and this test passes:

 it('correctly formats negated variable (issue #50)', () => {
            formatter.formattingOptions = {
                indentStyle: 'tabs',
                indentSpaceCount: 4,
                formatIndent: true,
                keywordCase: 'lower',
                typeCase: 'lower',
                compositeKeywords: 'split',
                removeTrailingWhiteSpace: true,
                formatInteriorWhitespace: true,
                insertSpaceBeforeFunctionParenthesis: false,
                insertSpaceBetweenEmptyCurlyBraces: false,
                insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: false,
                insertSpaceBetweenAssociativeArrayLiteralKeyAndColon: false,
                formatSingleLineCommentType: 'original',
                formatMultiLineObjectsAndArrays: true
            };

            formatEqual(`y = -x`);
        });
tbrixi commented 2 years ago

Hello, can confirm that on new project formatter working fine. Issue was resolved by deleting "node_modules" and new npm install.