public void CursorJustOutsideCommentStart()
        {
            document.TextContent = "<!-- -->";
            var selectionStartOffset = 0;
            var selectionEndOffset   = 0;

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.IsNull(commentRegion);
        }
        public void NoTextSelected()
        {
            document.TextContent = string.Empty;
            var selectionStartOffset = 0;
            var selectionEndOffset   = 0;

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.IsNull(commentRegion, "Should not be a comment region for an empty document");
        }
        public void FirstCharacterOfCommentStartSelected()
        {
            document.TextContent = "<!-- -->";
            var selectionStartOffset  = 0;
            var selectionEndOffset    = 1;
            var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 0, endOffset: 5);

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.AreEqual(expectedCommentRegion, commentRegion);
        }
        public void EntireCommentAndExtraTextSelected()
        {
            document.TextContent = "a<!-- -->";
            var selectionStartOffset  = 0;
            var selectionEndOffset    = 9;
            var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 1, endOffset: 6);

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.AreEqual(expectedCommentRegion, commentRegion);
        }
        public void CaretInsideCommentButNoSelectedText()
        {
            document.TextContent = "<!---->";
            var selectionStartOffset  = 4;
            var selectionEndOffset    = 4;
            var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 0, endOffset: 4);

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.AreEqual(expectedCommentRegion, commentRegion);
        }
Exemplo n.º 6
0
        public void LastCharacterOfCommentEndSelected()
        {
            document.TextContent = "<!-- -->";
            int selectionStartOffset = 7;
            int selectionEndOffset   = 8;
            BlockCommentRegion expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, 0, 5);

            BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.AreEqual(expectedCommentRegion, commentRegion);
        }
        public void TwoExistingBlockComments()
        {
            document.TextContent = "<a>\r\n" +
                                   "<!--<b></b>-->\r\n" +
                                   "\t<c></c>\r\n" +
                                   "<!--<d></d>-->\r\n" +
                                   "</a>";

            var selectedText         = "<c></c>";
            var selectionStartOffset = document.TextContent.IndexOf(selectedText);
            var selectionEndOffset   = selectionStartOffset + selectedText.Length;

            var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            Assert.IsNull(commentRegion);
        }
Exemplo n.º 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            //ICSharpCode.TextEditor.Document.TextMarker t = new TextMarker(10, 30, TextMarkerType.SolidBlock);

            //ICSharpCode.TextEditor.Util.TextUtility.RegionMatches(txtEditor.Document,0,30,"#");
            string commentStart = "#region";
            string commentEnd   = "#endregion";

            IDocument document = txtEditor.Document;// new DocumentFactory().CreateDocument();


            int selectionStartOffset = 0;
            int selectionEndOffset   = selectionStartOffset + document.TextContent.Length;

            BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);
        }