Change:
import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; import { Schemas } from 'vs/base/common/network'; <ins> import Severity from 'vs/base/common/severity'; import { toErrorMessage } from 'vs/base/common/errorMessage'; </ins> import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { IWorkingCopyHistoryEntry, IWorkingCopyHistoryService } from 'vs/workbench/services/workingCopy/common/workingCopyHistory'; import { API_OPEN_DIFF_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';

Discussion:
Issue Type: <bBug</bIf a file has been opened in a location in which VS Code uses sudo to save the file, afterwards the timeline doesn't show diff between saved versions and doesn't restore the file upon request. VS Code version: Code 1.67.0 (, 2022-05-04T12:08:42.978Z) OS version: Linux x64 5.17.5-zen1-1-zen Restricted Mode: No <details<summarySystem Info</summary </details<details<summaryExtensions (57)</summaryExtensionVersion ------ better-comments3.0.0 Bookmarks13.3.0 vscode-diff-viewer1.2.0 path-intellisense2.8.0 gitignore0.7.0 csharpier-vscode1.2.4 vscode-eslint2.2.2 gitlens12.0.6 vscode-html-css1.12.2 prettier-vscode9.5.0 shell-format7.2.2 copilot1.20.5902 cloudcode1.18.2 gc-excelviewer4.2.54 output-colorizer0.1.2 icon-fonts2.5.3 Ionide-fsharp6.0.3 vscode-csharp-snippets1.1.0 roslynator4.1.0 docomment0.1.30 vscode-colorize0.11.1 vscode-gutter-preview0.30.0 csharpextensions1.7.0 vscode-jumpy1.0.2 cool-language-support0.1.1 git-graph1.30.0 vscode-docker1.22.0 csharp1.24.4 dotnet-interactive-vscode1.0. vscode-dotnet-pack1.0.8 python2022.6.2 vscode-pylance2022.5.1 jupyter2022.4.

jupyter-keymap1.0.0 jupyter-renderers1.0.6 remote-containers0.234.0 remote-ssh0.80.0 remote-ssh-edit0.80.0 remote-wsl0.66.2 vscode-remote-extensionpack0.21.0 cpptools1.9.8 live-server0.2.12 idl0.3.1 es6-css-minify3.3.3 vscode-versionlens1.0.9 vscode-xml0.20.0 vscode-sort-json1.20.0 bash-debug0.3.9 partial-diff1.4.3 vscode-javascript-booster14.0.1 indenticator0.7.0 code-spell-checker2.1.11 teamhub15.0.6 vscode-pets1.10.0 sort-lines1.9.1 vscodeintellicode1.2.21 vscode-icons11.11.0 </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
Yeah good catch, this is because we use a fast operation that probably copies over file permissions instead of creating a new file and writing into it. We either need to fallback to such a copy operation or disable local history for files that are saved as sudo...
Hm nevermind, I cannot reproduce and in fact it should work because you are able to open the file before making a change without having to be sudo so the local file history is also able to show a diff. I just tested this with and was able to see changes in the local history. Anything I am missing?
Hmm actually it show the diff, it's only the first row/first change (which i see now is supposed to be the same as the most recent change) that doesn't show any differences. Restoring however doesn't seem to work. Nothing happens on click.
Splitting up into 2 issues: this here: we need to tell the user about the error and not behave as if restore worked