Preventing dirty writes in VSCode
VS Code will show you an error message when you try to save a file that cannot be saved because it has changed on disk–usually when two people are editing a document at the same time.
VS Code blocks saving the file to prevent overwriting changes that have been made outside of the editor.
In order to resolve the save conflict, click the Compare action in the error message to open a diff editor that will show you the contents of the file on disk (to the left) compared to the contents in VS Code (on the right):
Use the actions in the editor toolbar
to resolve the save conflict.
You can either Accept your changes and thereby overwriting any changes on disk,
or Revert to the version on disk. Reverting means that your changes will be lost.
In this case, you click the arrow in the middle line of diff editor –line 23– to resolve the save conflict by accepting other’s changes.
Then click the tick
icon to accept your changes and thereby overwriting any changes on disk. The diff editor will be closed automatically.
Note: The file will remain dirty and cannot be saved until you pick one of the two actions to resolve the conflict.
本作品采用《CC 协议》,转载必须注明作者和本文链接