Fix calculation of first fold when closing folds.

Because of the reuse we were doing with currentFold and
closestCommonParentFold, our original way of capturing
the first fold wasn't working. We now just look up the fold
at the foldStart location after we compute foldStart.
Drop some no-longer-used variables.
Remove folded attribute from attachment character when needed.

Before, when we were opening a top-level fold with folded
children, we would add the attachment character to the
child fold's first character, but we wouldn't remove the folded
attribute from it. This would mess up line start/end
calculations that now take the fold range into account, since
those calculations assume that the first character of a
closed fold will have the attachment attribute but not the
folded attribute.