Пример #1
0
        public int Insert(ITextDocument editor, string text)
        {
            int offset = editor.LocationToOffset(Location);

            using (var undo = editor.OpenUndoGroup()) {
                // TODO: Run formatter !!!
                // text = editor.FormatString (Location, text);

                var line            = editor.GetLineByOffset(offset);
                int insertionOffset = line.Offset + Location.Column - 1;
                offset = insertionOffset;
                InsertNewLine(editor, LineBefore, ref offset);
                int result = offset - insertionOffset;

                editor.InsertText(offset, text);
                offset += text.Length;
                InsertNewLine(editor, LineAfter, ref offset);
                return(result);
            }
        }
Пример #2
0
		public int Insert (ITextDocument editor, string text)
		{
			int offset = editor.LocationToOffset (Location);
			using (var undo = editor.OpenUndoGroup ()) {

				// TODO: Run formatter !!!
				// text = editor.FormatString (Location, text);

				var line = editor.GetLineByOffset (offset);
				int insertionOffset = line.Offset + Location.Column - 1;
				offset = insertionOffset;
				InsertNewLine (editor, LineBefore, ref offset);
				int result = offset - insertionOffset;

				editor.InsertText (offset, text);
				offset += text.Length;
				InsertNewLine (editor, LineAfter, ref offset);
				return result;
			}
		}