Issue with return values of new 3 argument prevind and nextind functions


#1

In cases where the number of characters plus the starting position is greater than ncodeunits(str)+1, nextind should really return (as documented) ncodeunits(str)+1.
Also, if nchar is 0, nextind and prevind should act the same as thisind, IMO.
prevind, if nchar is greater than the number of characters before the given position,
should really return a 0, instead of some negative number.

julia> prevind("foobar", 7, 10000)
-9993

julia> nextind("foobar", 1, 10000)
10001

julia> prevind("foobar", 1)
0

julia> nextind("foobar", 6)
7

(I discovered this after implementing these new functions for my Strs.jl package, and then comparing the results to nextind and prevind on String).


#2

There was a long discussion on GitHub. This is intentional and documented.


#3

What is the value of returning totally invalid indexes from prevind and nextind?
That is inconsistent with the 2 argument forms of the functions.

Also, that behavior isn’t in the docstring.