microsoft / microsoft/TypeScript-Sublime-Plugin
Auto-format after save doesn't work correctly on files opened after load
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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