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


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)

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

julia> prevind("foobar", 1)

julia> nextind("foobar", 6)

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


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


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.