Exemplo n.º 1
0
        /// <summary>
        ///     Default implementation for multiline comments.
        /// </summary>
        protected void SurroundSelectionWithBlockComment(ITextEditor editor, string blockStart, string blockEnd)
        {
            using (editor.Document.OpenUndoGroup())
            {
                int startOffset = editor.SelectionStart;
                int endOffset   = editor.SelectionStart + editor.SelectionLength;

                if (editor.SelectionLength == 0)
                {
                    IDocumentLine line = editor.Document.GetLineForOffset(editor.SelectionStart);
                    startOffset = line.Offset;
                    endOffset   = line.Offset + line.Length;
                }

                BlockCommentRegion region = FindSelectedCommentRegion(editor, blockStart, blockEnd);

                if (region != null)
                {
                    editor.Document.Remove(region.EndOffset, region.CommentEnd.Length);
                    editor.Document.Remove(region.StartOffset, region.CommentStart.Length);
                }
                else
                {
                    editor.Document.Insert(endOffset, blockEnd);
                    editor.Document.Insert(startOffset, blockStart);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void IndentLine(ITextEditor editor, IDocumentLine line)
        {
            IEditor document   = editor.Document;
            int     lineNumber = line.LineNumber;

            if (lineNumber <= 1)
            {
                return;
            }
            document.GetLine(lineNumber - 1);
            throw new NotImplementedException();
            //string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset);
            // copy indentation to line
            //string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset);
            //document.Replace(line.Offset, newIndentation.Length, indentation);
        }