microsoft / vscode-hexeditor

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

Edit mode and input byte insertion #503

Closed tomilho closed 4 months ago

tomilho commented 5 months ago

Opening a PR for some early feedback on the feature.

Introduces input byte insertion and edit mode to switch between insertion and replacing.

To choose between these, there is a edit mode that can be changed either in the status bar or through a command. editselect

To visually distinguish them inside the editor, each mode has an unique cursor on the focusedByte. When Inserting, the cursor is a text cursor and in Replacing, it is a box.

Inserting insertedit

Replacing replaceedit

At the moment, it is not possible to insert at the end of the file and there are some annoying bugs. But, hopefully, it provides a good picture on how input byte insertion/replacing can be.

connor4312 commented 4 months ago

Some comments, great job with this PR though, it looks super cool. Let me know if you want help with append behavior.

tomilho commented 4 months ago

Thank you for the taking the time to comment! I will carefully go through all of them tomorrow as it is getting late here. At the moment, I am not entirely sure if it is a good idea to have <AppendDataCell> separate to <DataCell> as they share many common behavior. Should I join them together or keep them separate? Thank you for the help!

connor4312 commented 4 months ago

I think it would probably be easier to try to join them together, since there's a lot of overlap between them. But I may be wrong, I'm not convicted one way or the other at this point.

tomilho commented 4 months ago

Apologies for the late message. I have gone through all the comments, so I hope the code is better now. At the moment, my biggest concern is related to #511 since, with this feature, it has become a lot easier to encounter it. I will try to figure out what is causing before opening the PR for merge.

Just want to say, again, thank you for the comments. They implicitly answered some questions I was having.

tomilho commented 4 months ago

I have somewhat figured out what is causing #511 , so I think we can merge this. I am still working on a proper fix, as the problem is rather complex.

tomilho commented 4 months ago

Thank you for the help and approving!

GitMensch commented 3 months ago

If there any chance to provide that for normal editors, giving the long standing (2015) https://github.com/microsoft/vscode/issues/1012?