private EditPoint Expand(TextPoint point, Action <EditPoint> foundAction) { EditPoint i = point.CreateEditPoint(); EditPoint result = null; do { var line = i.Line; var text = i.GetLine(); if (CodeCommentHelper.LineMatchesRegex(i, _commentLineRegex).Success) { result = i.CreateEditPoint(); foundAction(i); // If result and iterator line are the same, the found action (move line up or // down) did nothing. This means there is no point to keep searching, it would // create an infinite loop. if (result.Line == i.Line) { break; } } else { if (i != null && result != null && CodeCommentHelper.LineMatchesRegex(i, _codeLineRegex).Success) { result = null; } i = null; } } while (i != null); return(result); }