dprint-vscode icon indicating copy to clipboard operation
dprint-vscode copied to clipboard

VSCode Dprint extension requires two formatting passes to reach final output

Open alinco8 opened this issue 1 year ago • 0 comments

When using the Dprint extension in VSCode, formatting is applied in multiple stages:

  • First pass removes block braces ({})
  • Second pass converts to single-line

This requires manually formatting the file twice. In contrast, the CLI version completes the transformation in a single run.

Reproduction Steps

  1. Install the Dprint VSCode extension
  2. Use this .dprint.json config:
    {
      "typescript": {
        "quoteStyle": "alwaysSingle",
        "quoteProps": "asNeeded",
        "semiColons": "prefer",
        "singleBodyPosition": "sameLine",
        "useBraces": "preferNone"
      }
    }
    
  3. Format the following code:
    if (Math.random() > 0.5) {
        console.log('HI!');
    }
    
  4. First format: braces are removed
  5. Second format: line is compressed to one-liner

Expected Behavior

Formatting should complete in one pass, like the CLI version.

Actual Behavior

VSCode requires two passes to reach the same output.

Environment

  • VSCode Version: 1.97.2
  • Dprint Extension Version: 0.16.4
  • Dprint CLI Version: 0.49.1
  • OS: MacOS Sequoia 15.4

Notes

The CLI correctly applies multi-step transforms in one run. The VSCode extension applies only one step per format operation.

alinco8 avatar Apr 12 '25 12:04 alinco8