コード例 #1
0
 public bool Insert(Range position, string text, bool addNewline)
 {
     try
     {
         GetEditPointForRange(position)?.Insert(text + (addNewline ? Environment.NewLine : string.Empty));
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #2
0
 public bool Delete(Range range)
 {
     try
     {
         GetEditPointForRange(range)?.Delete(range.LineRange.Length);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #3
0
        private EditPoint GetEditPointForRange(Range range)
        {
            IVsTextLines textLines;
            int hr = _view.GetBuffer(out textLines);

            if (hr != VSConstants.S_OK || textLines == null)
            {
                return null;
            }

            object editPointObject;
            hr = textLines.CreateEditPoint(range.LineNumber, range.LineRange.Start, out editPointObject);
            EditPoint editPoint = editPointObject as EditPoint;

            if (hr != VSConstants.S_OK || editPoint == null)
            {
                return null;
            }

            return editPoint;
        }