private bool ReduceBoxSelectionToEditableBox(ref VirtualSnapshotPoint selectionTop, ref VirtualSnapshotPoint selectionBottom, bool isDelete)
            {
                int selectionTopColumn, selectionBottomColumn;
                ITextSnapshotLine selectionTopLine, selectionBottomLine;
                selectionTop.GetLineAndColumn(out selectionTopLine, out selectionTopColumn);
                selectionBottom.GetLineAndColumn(out selectionBottomLine, out selectionBottomColumn);

                int selectionLeftColumn, selectionRightColumn;
                bool horizontallyReversed = selectionTopColumn > selectionBottomColumn;

                if (horizontallyReversed)
                {
                    // bottom-left <-> top-right 
                    selectionLeftColumn = selectionBottomColumn;
                    selectionRightColumn = selectionTopColumn;
                }
                else
                {
                    // top-left <-> bottom-right
                    selectionLeftColumn = selectionTopColumn;
                    selectionRightColumn = selectionBottomColumn;
                }

                var selectionTopLeft = new VirtualSnapshotPoint(selectionTopLine, selectionLeftColumn);
                var selectionBottomRight = new VirtualSnapshotPoint(selectionBottomLine, selectionRightColumn);

                SnapshotPoint editable = GetClosestEditablePoint(selectionTopLeft.Position);
                int editableColumn;
                ITextSnapshotLine editableLine;
                editable.GetLineAndColumn(out editableLine, out editableColumn);

                Debug.Assert(selectionLeftColumn <= selectionRightColumn);
                Debug.Assert(selectionTopLine.LineNumber <= selectionBottomLine.LineNumber);

                if (editable > selectionBottomRight.Position)
                {
                    // entirely within readonly output region:
                    return false;
                }

                int minPromptLength, maxPromptLength;
                MeasurePrompts(editableLine.LineNumber, selectionBottomLine.LineNumber + 1, out minPromptLength, out maxPromptLength);

                bool result = true;
                if (isDelete)
                {
                    if (selectionLeftColumn > maxPromptLength || maxPromptLength == minPromptLength)
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = Math.Max(selectionLeftColumn, maxPromptLength); 
                    }
                }
                else
                {
                    if (selectionRightColumn < minPromptLength)
                    {
                        // entirely within readonly prompt region:
                        result = false;
                    }
                    else if (maxPromptLength > selectionRightColumn)
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = maxPromptLength;
                        selectionRightColumn = maxPromptLength;
                    }
                    else
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = Math.Max(maxPromptLength, selectionLeftColumn);
                    }
                }

                if (horizontallyReversed)
                {
                    // bottom-left <-> top-right 
                    selectionTop = new VirtualSnapshotPoint(selectionTopLine, selectionRightColumn);
                    selectionBottom = new VirtualSnapshotPoint(selectionBottomLine, selectionLeftColumn);
                }
                else
                {
                    // top-left <-> bottom-right
                    selectionTop = new VirtualSnapshotPoint(selectionTopLine, selectionLeftColumn);
                    selectionBottom = new VirtualSnapshotPoint(selectionBottomLine, selectionRightColumn);
                }

                return result;
            }