internal static void ShrinkSelection(MonoDevelop.Ide.Editor.TextEditor editor, Func <XmlParser> getTreeParser)
        {
            var selectionAnnotation = GetAnnotation(editor, getTreeParser);

            if (selectionAnnotation.NodePath.Count == 0)
            {
                return;
            }

            var newRegion = selectionAnnotation.Shrink();

            if (newRegion.HasValue)
            {
                editor.SetSelection(newRegion.Value.Begin, newRegion.Value.End);
            }
            else
            {
                editor.ClearSelection();
            }
        }
Exemplo n.º 2
0
 public static void DuplicateCurrentLine(TextEditor textEditor)
 {
     // Code from Mono.TextEditor.MiscActions.DuplicateLine
     using (var undoGroup = textEditor.OpenUndoGroup()) {
         if (textEditor.IsSomethingSelected)
         {
             var selectedText = textEditor.SelectedText;
             textEditor.ClearSelection();
             textEditor.InsertAtCaret(selectedText);
         }
         else
         {
             var line = textEditor.GetLine(textEditor.CaretLine);
             if (line == null)
             {
                 return;
             }
             textEditor.InsertText(line.Offset, textEditor.GetTextAt(line.SegmentIncludingDelimiter));
         }
     }
 }