bitst0rm-pub / Formatter

🧜‍♀️ A Sublime Text plugin to beautify and minify source code: CSS, SCSS, Sass, HTML, XML, SVG,JS,JavaScript, JSON, GraphQL, Markdown, TypeScript, Vue, Lua, YAML, Go, Perl, PHP, Python, Ruby, Rust, Haskell, Dart, Swift, Crystal, Bash, Shell, SQL, CSV, C, C++, C#, Objective-C, D, Java, Pawn, Julia, Proto, LaTeX, D2, Graphviz, Mermaid, PlantUML, etc
Other
100 stars 19 forks source link

Per-project Formatting problem #60

Closed husanjun closed 1 month ago

husanjun commented 1 month ago

Hi, bitst0rm

I tried using the per-project setup, the settings do not take effect when I open multiple items at the same time, and I can see from the console message that the previous settings are used

bitst0rm commented 1 month ago

Hi @husanjun

Thank you again for your bug report, much appreciated! It is indeed a bug, as Formatter does not see the newly opening project. I have fixed it to work with multi projects.

Update: I have released the update 1.5.5 containing both your PR and this fix.

husanjun commented 1 month ago

Hi,@bitst0rm

This issue is only partially fixed,multiple projects are open at the same time, and the configuration does not seem to follow when switching between projects

I submitted a fix and it worked fine #61

bitst0rm commented 1 month ago

Hi @husanjun

I will look at your fix closely soon. Thanks! Could you please post your .sublime-project content, but only the part which does not work with a short marker comment, so i can reproduce the issue, like my test with marker comment:

{
    "folders": [{
        "path": "."
    }],
    "settings": {
        "Formatter": {
            "debug": false, // -- DONT work, bug already found, updated soon
            "show_statusbar": true, // -- work
            "formatters": {
                "phpcsfixer": {
                    "format_on_save": true, // -- work
                    "config_path": {
                        "default": "/Users/admin/Documents/php_cs_fixer_rc.php" // -- work
                    }
                },
                "jsbeautifier": {
                    "format_on_save": true, // -- work
                    "syntaxes": ["js"], // -- work
                    "config_path": {
                        "default": "/Users/admin/Documents/jsbeautify_rc.json" // -- work
                    }
                }
            }
        }
    }
}
husanjun commented 1 month ago

.sublime-project

One uses .sublime-project setting and the other uses the Formatter.sublime-settings setting

When I need special processing in a single project, I configure it in .sublime-project, but this affects projects that are not configured with .sublime-project

husanjun commented 1 month ago

Formatter.sublime-settings

{
  "formatters":{
        "phpcsfixer": {
        "info": "https://github.com/FriendsOfPHP/PHP-CS-Fixer",
        "enable": true,
        "syntaxes": ["php"],
        "interpreter_path": ["php"],
        "executable_path": ["${packages}\\User\\php-cs-fixer"],
        "config_path": {
            "default": "${packages}\\User\\formatter.assets\\config\\php_cs_fixer_rc.php"
        }
        },
    }
}

project1.sublime-project

{
    "folders": [{
        "path": "."
    }],
    "settings": {
        "Formatter": {
            "formatters": {
                "phpcsfixer": {
                    "config_path": {
                        "default": "${packages}\\User\\formatter.assets\\config\\php_cs_fixer_rc_1.php" 
                    }
                }
            }
        }
    }
}

project2.sublime-project

{
    "folders": [{
        "path": "."
    }],
}

project2 uses project1's settings instead of Formatter.sublime-settings in some cases

bitst0rm commented 1 month ago

Thank you, @husanjun, for your help. I found the issue: the CONFIG does not get updated properly. Instead of using your pull request with a new global settings = {}, which would result in two nearly identical configurations which would last the memory, we will just update the CONFIG to reuse.

I have pushed a new branch husanjun_dev_test, could you please test it to see if it is the issue. It is ok on my side. if it is ok then i will rewrite it properly. Thanks

bitst0rm commented 1 month ago

@husanjun

I have fixed it in the master branch.

husanjun commented 1 month ago

@husanjun

I have fixed it in the master branch.

I tested it. It worked fine. Thank you

bitst0rm commented 1 month ago

Thank you for your all contributions. I release it now so you do not need to wait.