saros icon indicating copy to clipboard operation
saros copied to clipboard

Recovery uses editor content instead of on-disc content for recovery

Open tobous opened this issue 5 years ago • 0 comments

The WatchdogRecoveryHandler uses the editor content to determine the binary file content when creating a recovery file creation activity.

This handling can be an issue in corner cases as the editor content doesn't always match the on-disc content. (This is, for example, the case for IntelliJ, where all editor content is normalized to only use Unix line separators, regardless of which line separator is used in the file on disc.)

Solution Approach

A better solution would be to flush the file content to disc and then use the content on disc (which can be queried using IFile.getContents()).

Solution Approach - Normalization

A different approach is necessary if full content normalization is introduced to the core. At that point, we will differentiate between binary and non-binary files and always transfer the editor content for non-binary files.

So the new logic would have to check whether the file is non-binary, then query the normalized content and convert it to a byte array using the default charset chosen for the normalization (probably UTF-8).

tobous avatar Mar 23 '20 11:03 tobous