microsoft / vscode-hexeditor

VS Code Hex Editor
https://marketplace.visualstudio.com/items?itemName=ms-vscode.hexeditor
MIT License
530 stars 88 forks source link

Overwrite option doesn't work when a opened file is deleted #454

Closed lorsanta closed 9 months ago

lorsanta commented 1 year ago

Steps:

Instead of containing the expected data, the file now contains a sequence of zeros followed by the new byte.

The problem seems to be caused by how HexDocumentModel.save() is implemented. When a file is deleted, the model should rewrite the entire file instead of selectively writing to it.

Maybe a possible fix would be to add a isInConflictState attribute to the model?

zet23t commented 9 months ago

This bug is even more annoying:

alexr00 commented 8 months ago

@connor4312 how should this be verified? I can repro the original issue, but I don't see a pre-release version of the extension to install.

connor4312 commented 8 months ago

We just published a new version of the hex editor

Note that we just close the file when it's deleted: we don't page the entire file into memory, so we cannot reliably 'recover' it if it's deleted.