Beispiel #1
0
        private void ExpandSelectionOnPartialTokenSelect(ITextSelection selection, ITextRange tokenRange)
        {
            switch (selection.Type)
            {
            case SelectionType.InsertionPoint:
                // Snap selection to token on click
                if (tokenRange.StartPosition < selection.StartPosition && selection.EndPosition < tokenRange.EndPosition)
                {
                    selection.Expand(TextRangeUnit.Link);
                    InvokeTokenSelected(selection);
                }

                break;

            case SelectionType.Normal:
                // We do not want user to partially select a token since pasting to a partial token can break
                // the token tracking system, which can result in unwanted character formatting issues.
                if ((tokenRange.StartPosition <= selection.StartPosition && selection.EndPosition < tokenRange.EndPosition) ||
                    (tokenRange.StartPosition < selection.StartPosition && selection.EndPosition <= tokenRange.EndPosition))
                {
                    // TODO: Figure out how to expand selection without breaking selection flow (with Shift select or pointer sweep select)
                    selection.Expand(TextRangeUnit.Link);
                    InvokeTokenSelected(selection);
                }

                break;
            }
        }