Closed gleachkr closed 9 years ago
Thanks for the patch. Unfortunately I see some problems with it:
(1) It always deletes two bytes, even if the given character is encoded on 3 bytes. (2) Bytes above \x7F are not necessarily unicode bytes, they may be accented letters of a non-US codepage (non-utf encoding), in this case only one byte should be deleted.
I'd rather let vim decide on the length of the given character, something like this:
let chars = split(strpart(line, pos), '\zs')
let ch = split(strpart(line, pos), '\zs')[0]
let reg = reg . ch
let line = strpart( line, 0, pos ) . strpart( line, pos+len(ch) )
i.e. cut the current line at the cursor position, split it into characters (not bytes), take the length of the first character (which was the character at the cursor position).
I'll try to finalize the above logic, and make it work also for the backwards deletion case.
Ok, yes, those were the kinds of edge cases I was worried about. Your approach looks like a much better solution.
Addresses #13. There may still be some edge cases.