Пример #1
0
        public void TestUnCommentIndented()
        {
            var view = new MockTextView(
                new MockTextBuffer(@"function f(){
    //console.log('Hello');
    //console.log('Still here');
    console.log('Goodbye');
}"));

            view.Selection.Select(
                new SnapshotSpan(
                    view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start,
                    view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(2).End
                    ),
                false
                );

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"function f(){
    console.log('Hello');
    console.log('Still here');
    console.log('Goodbye');
}",
                            view.TextBuffer.CurrentSnapshot.GetText());
        }
        public void Comment() {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('Hello');
console.log('Goodbye');"));

            view.Selection.Select(
                new SnapshotSpan(view.TextBuffer.CurrentSnapshot, new Span(0, view.TextBuffer.CurrentSnapshot.Length)),
                false
            );

            view.CommentOrUncommentBlock(true);

            Assert.AreEqual(@"//console.log('Hello');
//console.log('Goodbye');",
                 view.TextBuffer.CurrentSnapshot.GetText());
        }
Пример #3
0
        public void TestCommentBlankLine()
        {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('hi');

console.log('bye');"));

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);

            view.CommentOrUncommentBlock(true);

            Assert.AreEqual(@"console.log('hi');

console.log('bye');",
                            view.TextBuffer.CurrentSnapshot.GetText());
        }
Пример #4
0
        public void TestComment()
        {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('Hello');
console.log('Goodbye');"));

            view.Selection.Select(
                new SnapshotSpan(view.TextBuffer.CurrentSnapshot, new Span(0, view.TextBuffer.CurrentSnapshot.Length)),
                false
                );

            view.CommentOrUncommentBlock(true);

            Assert.AreEqual(@"//console.log('Hello');
//console.log('Goodbye');",
                            view.TextBuffer.CurrentSnapshot.GetText());
        }
Пример #5
0
        public void TestCommentAfterCodeIsNotUncommented()
        {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('Hello');//comment that should stay a comment;
//console.log('Still here');//another comment that should stay a comment;
console.log('Goodbye');"));

            view.Selection.Select(
                new SnapshotSpan(view.TextBuffer.CurrentSnapshot, new Span(0, view.TextBuffer.CurrentSnapshot.GetText().IndexOf("console.log('Goodbye');"))),
                false
                );

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');//comment that should stay a comment;
console.log('Still here');//another comment that should stay a comment;
console.log('Goodbye');",
                            view.TextBuffer.CurrentSnapshot.GetText());
        }
        public void UnCommentCurrentLine() {
            var view = new MockTextView(
                new MockTextBuffer(@"//console.log('Hello');
//console.log('Goodbye');"));

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(0).Start);

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');
//console.log('Goodbye');",
                 view.TextBuffer.CurrentSnapshot.GetText());

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');
console.log('Goodbye');",
                view.TextBuffer.CurrentSnapshot.GetText());
        }
Пример #7
0
        public void TestUnCommentCurrentLine()
        {
            var view = new MockTextView(
                new MockTextBuffer(@"//console.log('Hello');
//console.log('Goodbye');"));

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(0).Start);

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');
//console.log('Goodbye');",
                            view.TextBuffer.CurrentSnapshot.GetText());

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');
console.log('Goodbye');",
                            view.TextBuffer.CurrentSnapshot.GetText());
        }
        public void CommentAfterCodeIsNotUncommented() {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('Hello');//comment that should stay a comment;
//console.log('Still here');//another comment that should stay a comment;
console.log('Goodbye');"));

            view.Selection.Select(
                new SnapshotSpan(view.TextBuffer.CurrentSnapshot, new Span(0, view.TextBuffer.CurrentSnapshot.GetText().IndexOf("console.log('Goodbye');"))),
                false
            );

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"console.log('Hello');//comment that should stay a comment;
console.log('Still here');//another comment that should stay a comment;
console.log('Goodbye');",
                view.TextBuffer.CurrentSnapshot.GetText());
        }
        public void UnCommentIndented() {
            var view = new MockTextView(
                new MockTextBuffer(@"function f(){
    //console.log('Hello');
    //console.log('Still here');
    console.log('Goodbye');
}"));

            view.Selection.Select(
                new SnapshotSpan(
                    view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start,
                    view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(2).End
                ),
                false
            );

            view.CommentOrUncommentBlock(false);

            Assert.AreEqual(@"function f(){
    console.log('Hello');
    console.log('Still here');
    console.log('Goodbye');
}",
                    view.TextBuffer.CurrentSnapshot.GetText());
        }
        public void CommentBlankLine() {
            var view = new MockTextView(
                new MockTextBuffer(@"console.log('hi');

console.log('bye');"));

            view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);

            view.CommentOrUncommentBlock(true);

            Assert.AreEqual(@"console.log('hi');

console.log('bye');",
             view.TextBuffer.CurrentSnapshot.GetText());
        }