Exemple #1
0
        /// <summary>
        ///     A TextSelection extension method that expand selection.
        /// </summary>
        /// <param name="selection">
        ///     The target to act on.
        /// </param>
        /// <returns>
        ///     .
        /// </returns>
        public static WiddenSelectionResult ExpandSelection(this TextSelection selection)
        {
            EditorPoints ep = selection.GetEditorPoints();

            // If nothing is selected, select the closest node.
            if (ep.IsEmpty)
            {
                selection.ResetSelection(ep);
                return(selection.SelectNode() ? WiddenSelectionResult.Success : WiddenSelectionResult.NodeSelectError);
            }
            // If a node or nodes are selected, select the parent.
            if (selection.IsNodeSelected() || selection.AreSiblingsSelected())
            {
                return(selection.SelectParent()
                           ? WiddenSelectionResult.Success
                           : WiddenSelectionResult.ParentSelectError);
            }
            return(WiddenSelectionResult.LogicError);
        }