Closed rleigh-codelibre closed 9 months ago
I don't know if this context is useful or not, but I have three binary files, main_bom_good_1.luab, main_bom_good_2.luab, main_bom_good_3.luab. The first two will reopen just fine. The last will not open without triggering more exceptions.
Overwriting main_bom_good_3.luab with main_bom_good_1.luab allowed BinEd to then open the file. The only content difference was main_bom_good_1.luab was \xEB\xBB\xBF
while main_bom_good_3.luab was \xEB\xBB\xB0
. More likely the overwrite changed some state within CLion which was triggering the failure?
I think I've found the trigger. It looks like an editor bug.
If I go to the first byte EB
and overwrite with EF
then the editor locks up. The first E
is OK, but as soon as I type the second character F
the editor locks up. Writing EE
works. Maybe a range validation bug?
Addition: The EB
to EF
change was actually made (and saved) when I restarted the IDE and checked the file content with another Hex editor (HxD), but that single-byte edit locked up the editor, preventing further edits, and the change was not reflected in the UI which continued to display EB
after the lockup.
Hi, thanks for the report. I was able to reproduce error by last steps you described (overwriting EF).
My guess is that there is UTF BOM processing in IntelliJ at play here when using IntelliJ native file handling. I'll try to investigate more, but it might be the case where I won't be able to fix this. https://en.wikipedia.org/wiki/Byte_order_mark
In the meantime / as a workaround it should be possible to use "Open in/Binary Editor" from context popup menu, which access file directly (but requires manual saving and cannot handle when file is changed by different activity at the same time).
Interesting, glad you could reproduce it. If it's not something which BinEd can work around, is this something worth raising with the IntelliJ devs on YouTrack?
I'll try your suggested workaround in the meantime. Thanks for responding so quickly!
I don't think they would have time to work on that...
I was using VirtualFile.getInputStream method, but it skips BOM header even when not valid... https://github.com/JetBrains/intellij-community/blob/391cf0adcd528d9903b45b7c685cff90db820fcb/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java#L711
Alternative is to rework wrapper to use VirtualFile.contentsToByteArray / VirtualFile.setBinaryContent, but that would mean to send content of the whole file when even single byte is modified. It will be probably noticeably slower especially for bigger files...
Modified in current development build, if you want to try it: https://bined.exbin.org/download/?bined-intellij-plugin.zip
Hi, I tried out the development build. Testing the failure scenario detailed above, I can no longer cause any exceptions to be raised while editing, so this looks good to me. Thanks so much for looking at this on your weekend!
Should be fixed in release 0.2.9.
Exceptions encountered when opening a new file which had been copied and pasted in the "Project" panel. The file had opened with BinEd, with an editor window being displayed:
Other BinEd editor windows continue to work properly following the errors:
CLion stack traces: