microsoft / TypeScript-Sublime-Plugin

IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
Apache License 2.0
1.72k stars 237 forks source link

Auto-format after save doesn't work correctly on files opened after load #779

Open caub opened 2 years ago

caub commented 2 years ago

I'm using Sublime build 4113, under linux (Lubuntu 18.04)

I've customized https://github.com/microsoft/TypeScript-Sublime-Plugin/blob/master/typescript/libs/editor_client.py#L110 by adding these options:

        format_options = {
            "tabSize": self.tab_size,
            "indentSize": self.indent_size,
            "convertTabsToSpaces": self.translate_tab_to_spaces,
            "insertSpaceAfterFunctionKeywordForAnonymousFunctions": True,
            "typescript.format.InsertSpaceAfterFunctionKeywordForAnonymousFunctions": True,
            "javascript.format.InsertSpaceAfterFunctionKeywordForAnonymousFunctions": True
        }

If I open a file modify it and save, the formatting works but doesn't respect these settings, so it'll format like this:

const fn = function(arg) { }

but then, if I close and reopen Sublime Text modify the file and save again, the formatting works correctly

const fn = function (arg) { }

Is there something I'm doing wrong? I know it's maybe hacky the way I modified my ~/.config/sublime-text-3/Packages/TypeScript/typescript/libs/editor_client.py setting directly

caub commented 2 years ago

I switched to LSP-typescript