Skip to content

Conversation

@RedCMD
Copy link
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

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 Fix FormatOnSave when modificationsIfAvailable 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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants