Closed bdlow closed 4 years ago
@bdlow previously commented (now deleted):
If Sublime inserts NUL's sporadically under certain conditions, and without knowing we save, the next time we open the file will be truncated, if we then unwittingly save again, we've potentially lost a lot of work.
So, you are saying that ST truncates files with NUL bytes when opening them? That'd be a different issue and definitely critical.
I hadn't tried opening a file containing NULs - I just did, and it's kinda weird. Sublime does NOT truncate the file, but it also doesn't open it as a regular text file.
Sublime presents the file contents as a hexdump, but editable as a text file. ~% echo "one\0two\0three" > /tmp/n.txt ~% subl -n /tmp/n.txt
Sublime shows as a hexdump: 6f6e 6500 7477 6f00 7468 7265 650a
The text is editable in some sort of weird mashup of a hex editor and text editor. Attempting to edit the file in this mode gives unpredictable results. This mode seems totally useless - presenting a hexdump without the actual structure of a hex editor is not very helpful. Seems like the far more sensible thing to do would be to present NULs as ^@.
Yes, that is expected or intended behavior. ST opens files with unprintable characters (like control characters <0x20) in hex mode. The built-in hex viewer is not really good, but at least there is a plugin that does it better.
Anyway, what I was confused about is this:
If Sublime inserts NUL's sporadically under certain conditions, and without knowing we save, the next time we open the file will be truncated, if we then unwittingly save again, we've potentially lost a lot of work.
Anyway, what I was confused about is this:
If Sublime inserts NUL's sporadically under certain conditions, and without knowing we save, the next time we open the file will be truncated, if we then unwittingly save again, we've potentially lost a lot of work.
That pertains to the how this issue pertained to the related thread. I've deleted the comment as I'd overlooked that this issue related to pasting and not opening. My bad.
Hm, now this whole discussion is ripped out of context. Tried my best.
Didn't see much point leaving it in; it's no longer relevant to this thread. Apologies for any confusion.
To clarify, I've just tested and Sublime does not truncate files when opening. Behaviour seems dependent on the file and where the NUL chars exist; sometimes Sublime opens them as hex and sometimes it opens them as text with embedded NUL characters.
Also copying text containing NULL's is truncated after the first nul: test3_log.txt
We've got a fix for this in the pipeline
Fixed in 4075
Pasting text that includes NULL characters shows up in Sublime 3 truncated at the first NULL.
Operating System: OSX 10.9.4 The version of Sublime Text: Build 3059 Any related software which may cause ST to act strangely: none, known
Repro: % echo "one\0two\0three" | pbcopy