Skip to content

Fix FormatOnSave when modificationsIfAvailable#283726

Merged
lszomoru merged 3 commits intomicrosoft:mainfrom
RedCMD:Fix_FormatOnSave_modificationsIfAvailable
Dec 16, 2025
Merged

Fix FormatOnSave when modificationsIfAvailable#283726
lszomoru merged 3 commits intomicrosoft:mainfrom
RedCMD:Fix_FormatOnSave_modificationsIfAvailable

Conversation

@RedCMD
Copy link
Copy Markdown
Contributor

@RedCMD RedCMD commented Dec 16, 2025

Fixes #241795 #253840

the Git extension was not ignoring ignored files when asked for original resource
causing diff to fail to open non-existence files

this allows FormatOnSave to work on ignored files when "editor.formatOnSaveMode": "modificationsIfAvailable" is set

path I followed:

const ranges = await this.instantiationService.invokeFunction(getModifiedRanges, isCodeEditor(editorOrModel) ? editorOrModel.getModel() : editorOrModel);

const original = await getOriginalResource(quickDiffService, modified.uri, modified.getLanguageId(), shouldSynchronizeModel(modified));

const quickDiffs = await quickDiffService.getQuickDiffs(uri, language, isSynchronized);

const originalResource = scoreValue > 0 ? await provider.getOriginalResource(uri) ?? undefined : undefined;

const result = await this.proxy.$provideSecondaryOriginalResource(this.handle, uri, CancellationToken.None);

return asPromise(() => sourceControl.quickDiffProvider!.provideOriginalResource!(uri, token))

async provideOriginalResource(uri: Uri): Promise<Uri | undefined> {

@vs-code-engineering
Copy link
Copy Markdown
Contributor

vs-code-engineering bot commented Dec 16, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/repository.ts
@RedCMD RedCMD changed the title Fix format on save modifications if available Dec 16, 2025
@jrieken jrieken assigned lszomoru and unassigned jrieken Dec 16, 2025
@lszomoru lszomoru enabled auto-merge (squash) December 16, 2025 11:58
@lszomoru
Copy link
Copy Markdown
Member

@RedCMD, thank you very much for your contribution!

@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 16, 2025
@lszomoru lszomoru merged commit 98a4b07 into microsoft:main Dec 16, 2025
17 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants