deadpixi / sam

An updated version of the sam text editor.
Other
436 stars 47 forks source link

Files get permanently marked as "dirty" #50

Closed ahamidullah closed 7 years ago

ahamidullah commented 7 years ago

Sam will occasionally decide a file is permanently "dirty" (has unsaved modifications) and saving the file no longer sets it to clean. This will happen to multiple files during extended use, though I haven't been able to figure out what triggers it.

deadpixi commented 7 years ago

I think the issue might be that the files in question are encoded using a different encoding from the systems-specified multibyte encoding.

Deadpixi sam, unlike the Plan 9 and netlib sam, is not limited to UTF-8 encoding, but rather will use any encoding supported by the host operating system. The encoding to use is determined by the LC_ALL and LC_CTYPE environment variables.

Both Deadpixi sam and older versions of sam will set the dirty flag on files that cannot be properly decoded or that contain null bytes; this is intentional, as it is impossible for sam to write the file back out and have it be identical to what was read in since information was lost during the failed decoding.

I've pushed some code up that will still allow files that aren't validly encoded to be edited, while throwing a warning. Please note that when writing out such files, information may be lost.

Thanks again!

deadpixi commented 7 years ago

@ahamidullah I'm going to close this bug, please reopen it if the problem persists.