Skip to content

Format on Save doesn't work for files outside of source control #241795

@dsent

Description

@dsent

Type: Bug

Steps to Reproduce:

  1. Create a file and add it to .gitignore
  2. Enable these options:
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "modificationsIfAvailable"
  3. Add a formatter for a file type (in my case, JSON with Comments)
  4. Check that manual formatting work (F1 → Format File)
  5. Modify the file in a way that should be fixed by a formatter (e.g., indentation).
  6. Save the file.

What should happen?

  • The file gets formatted (as source control is not available for the file, the whole file should be formatted, as per modificationsIfAvailable setting)

What actually happens?

  • It doesn't.

Workaround:

  • Change "editor.formatOnSaveMode" to "file".

Error log (the relevant line, I believe):

2025-02-25 03:58:38.000 [error] [Window] Error: Unable to read file 'git:/c:/Users/dsent/Dropbox/Code/<redacted>/concierge/.vscode/concierge.code-workspace.git?{"path":"c:\\Users\\dsent\\Dropbox\\Code\\<redacted>\\concierge\\.vscode\\concierge.code-workspace","ref":""}' (Error: Unable to resolve nonexistent file 'git:/c:/Users/dsent/Dropbox/Code/<redacted>/concierge/.vscode/concierge.code-workspace.git?{"path":"c:\\Users\\dsent\\Dropbox\\Code\\<redacted>\\concierge\\.vscode\\concierge.code-workspace","ref":""}')
    at nct.F (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3202:64742)
    at nct.D (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3202:64567)
    at async Tct.M (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3203:9257)
    at async Tct.readStream (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3203:9032)
    at async Zge.Eb (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1268:12151)
    at async Zge.resolve (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1268:10626)
    at async Ict.W (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3203:5889)
    at async Q9e.r (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1268:21104)
    at async zpt.acquire (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:27:3125)
    at async Z9e.createModelReference (vscode-file://vscode-app/c:/Users/dsent/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1268:22660)

VS Code version: Code 1.97.2 (e54c774, 2025-02-12T23:20:35.343Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.73GB (10.07GB free)
Process Argv --disable-extensions --crash-reporter-id 5666f496-bf09-4faa-a5fb-21e77b7ab24d
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31222730
jda6j935:31233686
copilothoveroff:31245427

Metadata

Metadata

Assignees

Labels

formattingSource formatter issuesinfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions