Ensure minCloseDepth doesn't go negative in closeFold:inRange:levels:.

When minCloseDepth goes negative, it actually goes way
positive, breaking the fold close. We do this by seeing if the
min close depth would become negative, and limiting it to
1 in those cases.
Only try to find a parent fold to close if there is room to do so.

Before, when closing a fold at a given location, we would
push through parents even if the current fold’s depth was
equal to the minimum close depth, which meant we could
try to close folds above the minimum depth. We no longer
do that.

This only happened when folds had the same start location
as their parents and we were closing one of the child folds.
Add support for folds that end at the same place as their parent.
Only mark the first character of a folded range with attachments.

Before we were checking if the current fold was the same as
the first fold, but that is also true if we go through a child fold
and then back to the first fold in a later range. In those
cases we don’t want to mark the first character in the current
range with the attachment attribute.

End result, we now just check if we’re closing this fold and
the start of the current range is the start of the fold area.
In that case, we mark it with the attachment attribute.