Fix replacing colors with "0x" prefix with length different than 6
commite135da8a79fa2a96d836b18159b535d0f7294ecd
authorColomban Wendling <ban@herbesfolles.org>
Wed, 9 Apr 2014 00:57:10 +0000 (9 02:57 +0200)
committerColomban Wendling <ban@herbesfolles.org>
Wed, 9 Apr 2014 01:06:49 +0000 (9 03:06 +0200)
tree3747de4362892af0736a40fbc913e7e0bf40ea9f
parentab6390fc8cd49bea62a94e9efcd9b30e9e1b61c8
Fix replacing colors with "0x" prefix with length different than 6

We used to assume that if the selected text started with "0x" when
inserting a color, we had to replace exactly 6 bytes after the "0x"
prefix.  Although this is generally the case as most color formats use
6 hexadecimal digits, it still would erase either too many or too few
characters if actually replacing something shorter (i.e. "0xfff") or
longer (i.e. "0xffffffffffff").

It could even partially override multi-byte characters if the 8th byte
after the selection start was in the middle of a character, as the
length was in bytes and not characters.

Fix this by honoring the actual selection end.
src/editor.c