Fix copy/cut functions
The following Merge Request (MR) has been forwarded from GitHub in order to prevent the GNOME Project from losing contributions coming from un-official channels. And for contributors to not see their valuable contributions not being accounted for.
Github handle: hermanndetz
Patch URL: https://github.com/GNOME/ghex/pull/2.patch
Body of the MR:
The length of the selection was previously calculated as (end - start), which led to the unwanted behavior that if e.g. two bytes were selected, the length (offset difference) calculated to one and therefore only one byte was actually copied to the clipboard and deleted from the document in the case of a cut operation. The current version calculates the correct length of (end - start) + 1.
Furthermore, a trailing 0x00 is added to the data that are copied to the clipboard. Otherwise, the paste command has now way of knowing the length. This still leaves an issue if a series of bytes containing one or more 0x00 are copied to the clipboard. They are copied correctly, but the paste command has now way of knowing the correct length in that case.