microsoft / microsoft/TypeScript-Sublime-Plugin

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

Open
#779 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
236
Avg merge
21d 13h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with typescript/libs/editor_client.py around line 110 and reproduce the formatting difference between a newly opened file and one reopened after restarting Sublime Text. Trace when the format options are initialized or applied, and consider the issue done when the configured spacing is respected on the first save without restarting the editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python, typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.