2015-07-12 17:53 GMT+02:00 Bram Moolenaar <
Br...@moolenaar.net>:
>
> Rob Wu wrote:
>
>> The counted number of bytes is decreased if 'bin' and 'noeol' are set.
>> This is incorrect, and the logic should only apply when the requested
>> line is the last line in the buffer.
>>
>> Test cases:
>> vim -b <(printf '123\n567') +':echo line2byte(1)'
>> Expected: 1
>> Actual : -1
>>
>> vim -b <(printf '123\n567') +':echo line2byte(2)'
>> Expected: 5
>> Actual : 4
>>
>> vim -b <(printf '123\r\n678') +':echo line2byte(2)'
>> Expected: 6
>> Actual : 5
>>
>> vim -b <(printf '123\n567') +':echo line2byte(3)'
>> Expected: 9
>> Actual : 8
>>
>> vim -b <(printf '123\r\n678') +':echo line2byte(3)'
>> Expected: 10 (not 11, because in binary mode fileformat is ignored,
>> so pressing enter adds a LF and not a CR LF).
>> Actual : 9
>
> Thanks for the patch. I notice there aren't any tests for line2byte(),
> perhaps someone can create them?
I've added some manual tests to my commit description. You could copy
them and add more tests to avoid regressions. I just started with Vim
these tests. Thanks for your fast response!