private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
		{
			if (changes.Count > 0)
			{
				double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
				double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;

				for (int i = 1; i < changes.Count; ++i)
				{
					double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
					if (yBottom < y)
					{
						drawingContext.DrawRectangle(
							brush,
							null,
							new Rect(0, yTop, markerWidth, yBottom - yTop));

						yTop = y;
					}

					yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
				}

				drawingContext.DrawRectangle(
					brush,
					null,
					new Rect(0, yTop, markerWidth, yBottom - yTop));
			}
		}
        public NormalizedSnapshotSpanCollection UncommentSpans(NormalizedSnapshotSpanCollection spans)
        {
            Contract.Requires<ArgumentNullException>(spans != null, "spans");
            Contract.Ensures(Contract.Result<NormalizedSnapshotSpanCollection>() != null);

            throw new NotImplementedException();
        }
 public void GetOverarchingSpan2()
 {
     var spans = new NormalizedSnapshotSpanCollection();
     _selection.SetupGet(x => x.SelectedSpans).Returns(spans).Verifiable();
     Assert.True(TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).IsNone());
     _selection.Verify();
 }
        public void FormattedStringBuilderEndToEnd1()
        {
            var classificationFormatMap = new MockClassificationFormatMap();
            var htmlMarkupProvider = new HtmlMarkupProvider(
                classificationFormatMap,
                MockClassificationType.Default,
                Brushes.White);
            var classifier = new MockClassifier();

            var formattedStringBuilder = new FormattedStringBuilder(
                htmlMarkupProvider,
                classifier,
                MockClassificationType.Default,
                waitIndicator: null);

            var snapshot = new MockTextSnapshot("bla");
            var spans = new NormalizedSnapshotSpanCollection(new []
            {
                new SnapshotSpan(snapshot, 0, 3)
            });

            var actualResult = formattedStringBuilder.AppendSnapshotSpans(spans);
            var expectedResult = "<pre style=\"font-family:Consolas;font-size:12;color:black;background:white;\">b<span style=\"color:blue;\">l</span>a\r\n</pre>";

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #5
0
		public void Add(ISynchronousClassifier classifier, NormalizedSnapshotSpanCollection spans, CancellationToken cancellationToken) {
			if (classifier == null)
				throw new ArgumentNullException(nameof(classifier));
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			foreach (var span in spans) {
				if (spansCount > 0)
					htmlWriter.WriteRaw(delimiter);
				spansCount++;
				var tagSpans = classifier.GetClassificationSpans(span, cancellationToken);
				var text = span.GetText();
				int pos = span.Start.Position;
				foreach (var tagSpan in tagSpans) {
					if (pos < tagSpan.Span.Start) {
						WriteCss(classificationFormatMap.DefaultTextProperties);
						htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, tagSpan.Span.Start.Position - pos);
					}
					WriteCss(classificationFormatMap.GetTextProperties(tagSpan.ClassificationType));
					htmlWriter.WriteSpan(cssWriter.ToString(), text, tagSpan.Span.Start - span.Start.Position, tagSpan.Span.Length);
					pos = tagSpan.Span.End;
				}
				if (pos < span.End) {
					WriteCss(classificationFormatMap.DefaultTextProperties);
					htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, span.End.Position - pos);
				}
			}
		}
		string GenerateHtmlFragmentCore(NormalizedSnapshotSpanCollection spans, ITextView textView, string delimiter, CancellationToken cancellationToken) {
			ISynchronousClassifier classifier = null;
			try {
				int tabSize;
				IClassificationFormatMap classificationFormatMap;
				if (textView != null) {
					classifier = synchronousViewClassifierAggregatorService.GetSynchronousClassifier(textView);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);
					tabSize = textView.Options.GetTabSize();
				}
				else {
					classifier = spans.Count == 0 ? null : synchronousClassifierAggregatorService.GetSynchronousClassifier(spans[0].Snapshot.TextBuffer);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.TextEditor);
					tabSize = defaultTabSize;
				}
				tabSize = OptionsHelpers.FilterTabSize(tabSize);

				var builder = new HtmlBuilder(classificationFormatMap, delimiter, tabSize);
				if (spans.Count != 0)
					builder.Add(classifier, spans, cancellationToken);
				return builder.Create();
			}
			finally {
				(classifier as IDisposable)?.Dispose();
			}
		}
 public void CalculateForBlock3()
 {
     var buffer = EditorUtil.CreateBuffer("dog", "cat", "chicken");
     var col = new NormalizedSnapshotSpanCollection(buffer.GetSpan(0, 2));
     var span = _calcRaw.CalculateForBlock(buffer.GetLine(1).Start.Add(1), col);
     Assert.IsTrue(span.IsMultiple);
     Assert.AreEqual(buffer.GetLine(1).Start.Add(1).GetSpan(2), span.AsMultiple().Item2[0]);
 }
		public string GenerateHtmlFragment(NormalizedSnapshotSpanCollection spans, string delimiter, CancellationToken cancellationToken) {
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			if (delimiter == null)
				throw new ArgumentNullException(nameof(delimiter));

			return GenerateHtmlFragmentCore(spans, null, delimiter, cancellationToken);
		}
        private static IEnumerable<ITagSpan<OutliningRegionTag>> GetTags(string input)
        {
            var buffer = new FakeTextBuffer(input);
            var tagger = new TemplateOutliningTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            return tagger.GetTags(snapshotSpans);
        }
Exemple #10
0
 public void GetOverarchingSpan3()
 {
     var buffer = CreateTextBuffer("foo bar");
     var span = buffer.GetLineRange(0).Extent;
     var col = new NormalizedSnapshotSpanCollection(span);
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.Equal(span, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
Exemple #11
0
 public void GetOverarchingSpan4()
 {
     var buffer = CreateTextBuffer("foo", "baz", "bar");
     var span1 = buffer.GetLineRange(0).Extent;
     var span2 = buffer.GetLineRange(0, 1).Extent;
     var col = new NormalizedSnapshotSpanCollection(new SnapshotSpan[] { span1, span2 });
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.AreEqual(buffer.GetLineRange(0, 1).Extent, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
        public static void GetTagsReturnsErrorSpanForSemanticError()
        {
            var buffer = new FakeTextBuffer("<#@ include file=\" \" #>");
            var tagger = new TemplateErrorTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            ITagSpan<ErrorTag> errorSpan = tagger.GetTags(snapshotSpans).Single();

            Assert.Equal(new Span(12, 8), errorSpan.Span);
            Assert.Contains("File", (string)errorSpan.Tag.ToolTipContent, StringComparison.OrdinalIgnoreCase);
        }
Exemple #13
0
 public void ShouldClassifyScenario()
 {
     TestInitialise("Features/gherkin.feature");
     var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
     var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
     var tags = playTagger.GetTags(spanCollection);
     var tag = tags.First(_ => _.Span.GetText().StartsWith("  Scenario: SC2")).Tag;
     Assert.AreEqual("Scenario: SC2" + Environment.NewLine +
                     "  Given something" + Environment.NewLine +
                     "  When some event occurs" + Environment.NewLine +
                     "  Then there is some outcome", tag.GetText());
 }
        private static bool IsComment(SnapshotPoint position)
        {
            if (position.Position < 2)
                return false;

            var tagger = position.Snapshot.TextBuffer.Properties.GetProperty<ITagger<ClassificationTag>>(jsTaggerType);

            Span span = Span.FromBounds(position.Position - 1, position.Position);
            var spans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(position.Snapshot, span));
            var classifications = tagger.GetTags(spans);

            return classifications.Any(c => c.Tag.ClassificationType.IsOfType("comment"));
        }
        public static IElisionBuffer CreateElisionBufferWithoutIndentation(
            this IProjectionBufferFactoryService factoryService,
            IEditorOptions editorOptions,
            IContentType contentType,
            IEnumerable<SnapshotSpan> exposedSpans)
        {
            var spans = new NormalizedSnapshotSpanCollection(exposedSpans);

            if (spans.Count > 0)
            {
                // BUG(6335): We have to make sure that the spans refer to the current snapshot of
                // the buffer.
                var buffer = spans.First().Snapshot.TextBuffer;
                var currentSnapshot = buffer.CurrentSnapshot;
                spans = new NormalizedSnapshotSpanCollection(
                    spans.Select(s => s.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive)));
            }

            contentType = contentType ?? factoryService.ProjectionContentType;
            var elisionBuffer = factoryService.CreateElisionBuffer(
                null, spans, ElisionBufferOptions.None, contentType);

            if (spans.Count > 0)
            {
                var snapshot = spans.First().Snapshot;
                var buffer = snapshot.TextBuffer;

                // We need to figure out the shorted indentation level of the exposed lines.  We'll
                // then remove that indentation from all lines.
                var indentationColumn = DetermineIndentationColumn(editorOptions, spans);

                var spansToElide = new List<Span>();

                foreach (var span in spans)
                {
                    var startLineNumber = snapshot.GetLineNumberFromPosition(span.Start);
                    var endLineNumber = snapshot.GetLineNumberFromPosition(span.End);

                    for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
                    {
                        var line = snapshot.GetLineFromLineNumber(lineNumber);
                        var lineOffsetOfColumn = line.GetLineOffsetFromColumn(indentationColumn, editorOptions);
                        spansToElide.Add(Span.FromBounds(line.Start, line.Start + lineOffsetOfColumn));
                    }
                }

                elisionBuffer.ElideSpans(new NormalizedSpanCollection(spansToElide));
            }

            return elisionBuffer;
        }
 public void CalculateForBlock4()
 {
     var buffer = EditorUtil.CreateBuffer("dog again", "cat again", "chicken");
     var col = new NormalizedSnapshotSpanCollection(new SnapshotSpan[]
     {
         buffer.GetLine(0).Start.GetSpan(2),
         buffer.GetLine(1).Start.GetSpan(2)
     });
     var span = _calcRaw.CalculateForBlock(buffer.GetLine(1).Start, col);
     Assert.IsTrue(span.IsMultiple);
     col = span.AsMultiple().item2;
     Assert.AreEqual(buffer.GetLine(1).Start.GetSpan(2), col[0]);
     Assert.AreEqual(buffer.GetLine(2).Start.GetSpan(2), col[1]);
 }
		private IEnumerable<SnapshotSpan> Split(SnapshotSpan span, IEnumerable<SnapshotSpan> remove) {
			var removeNorm = new NormalizedSnapshotSpanCollection(remove);
			foreach (var r in removeNorm.OrderBy(x => x.Start.Position)) {
				if (r.Start < span.End) {
					if (r.Start > span.Start) {
						yield return new SnapshotSpan(span.Start, r.Start);
					}
					if (r.End < span.End) {
						span = new SnapshotSpan(r.End, span.End);
					} else {
						yield break;
					}
				}
			}
			yield return span;
		}
Exemple #18
0
        public void ShouldClassifyScenarioWithExamples()
        {
            TestInitialise("Features/gherkin.feature");
            var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
            var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
            var tags = playTagger.GetTags(spanCollection);
            var tag = tags.First(span => span.Span.GetText().StartsWith("  Scenario: SC1")).Tag;

            Assert.AreEqual("Scenario: SC1" + Environment.NewLine +
                            "  Given numbers [left] and [right]" + Environment.NewLine +
                            "  When I add the numbers" + Environment.NewLine +
                            "  Then the sum is [sum]" + Environment.NewLine +
                            "Examples:" + Environment.NewLine +
                            "     | left | right | sum |" + Environment.NewLine +
                            "     | 1 | 2 | 3 |" + Environment.NewLine +
                            "     | 3 | 4 | 7 |", tag.GetText());
        }
        public void CreateRegionsAround_SelectionAtEndOfDocument()
        {
            var textBuffer = GetCSharpTextBuffer("Outlining1.txt");
              var snapshot = textBuffer.CurrentSnapshot;
              var outlining = SelectionOutliningManager.Get(textBuffer);

              int lineCount = snapshot.LineCount;
              var selectionSpan = GetSpanFromLines(snapshot, lineCount-10, lineCount-1);
              outlining.CreateRegionsAround(selectionSpan);

              // validate GetTags() gives us two spans
              var allDocument = new NormalizedSnapshotSpanCollection(snapshot.GetSpan());
              var tags = outlining.GetTags(allDocument).ToList();

              var span1 = GetSpanFromLines(snapshot, 0, (lineCount - 10)-1);
              Assert.Equal(span1, tags.First());
        }
        public IEnumerable<BracePos> BracesInSpans(NormalizedSnapshotSpanCollection spans)
        {
            if ( ScanIsUnnecessary() ) yield break;

              for ( int i = 0; i < spans.Count; i++ ) {
            var wantedSpan = spans[i];
            EnsureLinesInPreferredSpan(wantedSpan);
            int startIndex = FindIndexOfBraceAtOrAfter(wantedSpan.Start);
            if ( startIndex < 0 ) {
              continue;
            }
            for ( int j = startIndex; j < braces.Count; j++ ) {
              BracePos bp = braces[j];
              if ( bp.Position > wantedSpan.End ) break;
              yield return bp;
            }
              }
        }
		public void Render(DrawingContext drawingContext)
		{
			if (!HighlightWordTaggerProvider.Taggers.ContainsKey(_textView))
			{
				return;
			}

			NormalizedSnapshotSpanCollection spans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(_textView.TextSnapshot, 0, _textView.TextSnapshot.Length));
			IEnumerable<ITagSpan<HighlightWordTag>> tags = HighlightWordTaggerProvider.Taggers[_textView].GetTags(spans);
			List<SnapshotSpan> highlightList = new List<SnapshotSpan>();
			foreach (ITagSpan<HighlightWordTag> highlight in tags)
			{
				highlightList.Add(highlight.Span);
			}

			NormalizedSnapshotSpanCollection highlights = new NormalizedSnapshotSpanCollection(highlightList);

			if (highlights.Count > 0)
			{
				double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(highlights[0].Start)) + markerStartOffset;
				double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(highlights[0].End)) + markerEndOffset;

				for (int i = 1; i < highlights.Count; ++i)
				{
					double y = _scrollBar.GetYCoordinateOfBufferPosition(highlights[i].Start) + markerStartOffset;
					if (yBottom < y)
					{
						drawingContext.DrawRectangle(
							Colors.HighlightsBrush,
							null,
							new Rect(_scrollBar.Width - markerWidth, yTop, markerWidth, yBottom - yTop));

						yTop = y;
					}

					yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(highlights[i].End)) + markerEndOffset;
				}

				drawingContext.DrawRectangle(
					Colors.HighlightsBrush,
					null,
					new Rect(_scrollBar.Width - markerWidth, yTop, markerWidth, yBottom - yTop));
			}
		}
		public Classifier(CoffeeOverview overview, IClassificationTypeRegistryService classificationRegistry) {
			this.overview = overview;
			this.clsCoffeeString = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeString);
			this.clsCoffeeIdentifier = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeIdentifier);
			this.clsCoffeeKeyword = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeKeyword);
			this.clsCoffeeNumericLiteral = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeNumericLiteral);
			this.clsCoffeeComment = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeComment);
			overview.MultiLinesChanged += (o, e) => {
				if (this.latestSnapshot != null && this.ClassificationChanged != null) {
					var spans = new NormalizedSnapshotSpanCollection(
						e.Added.Concat(e.Removed)
						.Select(x => x.Span.GetSpan(this.latestSnapshot)));
					foreach (var span in spans) {
						var args = new ClassificationChangedEventArgs(span);
						this.ClassificationChanged(this, args);
					}
				}
			};
		}
        public void CreateRegionsAround_PartialLines()
        {
            var textBuffer = GetCSharpTextBuffer("Outlining1.txt");
              var snapshot = textBuffer.CurrentSnapshot;
              var outlining = SelectionOutliningManager.Get(textBuffer);

              var selectionSpan = GetSpanFromLines(snapshot, 9, 15);
              selectionSpan = new SnapshotSpan(selectionSpan.Start + 10, selectionSpan.End - 2);
              outlining.CreateRegionsAround(selectionSpan);

              // validate GetTags() gives us two spans
              var allDocument = new NormalizedSnapshotSpanCollection(snapshot.GetSpan());
              var tags = outlining.GetTags(allDocument).ToList();

              var span1 = GetSpanFromLines(snapshot, 0, 8);
              Assert.Equal(span1, tags.First());

              var span2 = GetSpanFromLines(snapshot, 16, snapshot.LineCount-1);
              Assert.Equal(span2, tags.Last());
        }
Exemple #24
0
        public void ShouldClassifyScenarioWithInlineTable()
        {
            TestInitialise("Features/gherkin.feature");

            var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
            var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
            var tags = playTagger.GetTags(spanCollection);
            var tag = tags.First(span => span.Span.GetText().StartsWith("  Scenario: inline table")).Tag;

            Assert.AreEqual("Scenario: inline table" + Environment.NewLine +
                            "  Given the following people exists:" + Environment.NewLine +
                            "     | Name | Country |" + Environment.NewLine +
                            "     | Morgan Persson | Sweden |" + Environment.NewLine +
                            "     | Jimmy Nilsson | Sweden |" + Environment.NewLine +
                            "     | Jimmy bogard | USA |" + Environment.NewLine +
                            "  When I search for people in sweden" + Environment.NewLine +
                            "  Then I should get:" + Environment.NewLine +
                            "     | Name |" + Environment.NewLine +
                            "     | Morgan Persson |" + Environment.NewLine +
                            "     | Jimmy Nilsson |", tag.GetText());
        }
		internal static NormalizedSnapshotSpanCollection[] GetUnifiedChanges(ITextSnapshot snapshot, IEnumerable<IMappingTagSpan<ChangeTag>> tags)
		{
			List<SnapshotSpan>[] unnormalizedChanges = new List<SnapshotSpan>[4]
			{
				null,
				new List<SnapshotSpan>(),
				new List<SnapshotSpan>(),
				new List<SnapshotSpan>()
			};

			foreach (IMappingTagSpan<ChangeTag> change in tags)
			{
				unnormalizedChanges[(int)change.Tag.ChangeTypes].AddRange(change.Span.GetSpans(snapshot));
			}

			NormalizedSnapshotSpanCollection[] changes = new NormalizedSnapshotSpanCollection[4];
			for (int i = 1; (i <= 3); ++i)
			{
				changes[i] = new NormalizedSnapshotSpanCollection(unnormalizedChanges[i]);
			}

			return changes;
		}
Exemple #26
0
        public string GenerateHtml(NormalizedSnapshotSpanCollection spans, IWpfTextView textView)
        {
            if (spans == null || spans.Count == 0)
            {
                return "";
            }

            // this will trigger loading of the package
            // so we can ensure ToolsOptionsPage gets created and
            // ToolsOptionsPage.Instance gets set
            var dte = (_DTE)_serviceProvider.GetService(typeof(_DTE));
            var props = dte.Properties[CopyAsHtmlPackage.CategoryName, CopyAsHtmlPackage.PageName];

            IClassificationFormatMap formatMap = _classificationFormatMappingService.GetClassificationFormatMap(textView);
            IClassificationType defaultClassificationType = _classificationTypeRegistry.GetClassificationType("text");
            HtmlMarkupProvider htmlMarkupProvider = new HtmlMarkupProvider(
                formatMap,
                defaultClassificationType,
                textView.Background);
            IClassifier classifier = _classifierAggregatorService.GetClassifier(textView.TextBuffer);

            var formattedStringBuilder = new FormattedStringBuilder(
                htmlMarkupProvider,
                classifier,
                defaultClassificationType,
                this.WaitIndicator);

            string result = formattedStringBuilder.AppendSnapshotSpans(spans);

            var classifierDispose = classifier as System.IDisposable;
            if (classifierDispose != null)
            {
                classifierDispose.Dispose();
            }

            return result;
        }
        public virtual NormalizedSnapshotSpanCollection UncommentSpans(NormalizedSnapshotSpanCollection spans)
        {
            List<SnapshotSpan> result = new List<SnapshotSpan>();

            if (spans.Count == 0)
                return new NormalizedSnapshotSpanCollection();

            var undoHistory = TextUndoHistoryRegistry.RegisterHistory(TextView);
            using (var transaction = undoHistory.CreateTransaction("Uncomment Selection"))
            {
                ITextSnapshot snapshot = spans[0].Snapshot;

                using (var edit = snapshot.TextBuffer.CreateEdit())
                {
                    foreach (var span in spans)
                    {
                        var selection = UncommentSpan(span, edit);
                        result.Add(selection);
                    }

                    edit.Apply();
                }

                if (snapshot != TextView.TextSnapshot)
                    transaction.Complete();
            }

            if (result.Count > 1)
                result.RemoveAll(span => span.IsEmpty);

            var target = TextView.TextBuffer.CurrentSnapshot;
            for (int i = 0; i < result.Count; i++)
            {
                result[i] = result[i].TranslateTo(target, SpanTrackingMode.EdgeInclusive);
            }

            return new NormalizedSnapshotSpanCollection(result);
        }
        public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(this IGherkinFileScope gherkinFileScope, NormalizedSnapshotSpanCollection spans)
        {
            if (gherkinFileScope == null)
                return new ITagSpan<IOutliningRegionTag>[0];

            var result = new List<ITagSpan<IOutliningRegionTag>>();
            foreach (var gherkinFileBlock in gherkinFileScope.GetAllBlocks())
            {
                result.AddRange(gherkinFileBlock.OutliningRegions); //TODO: optimize
            }
            return result;
        }
            public override void PostprocessMouseLeftButtonUp(MouseButtonEventArgs e)
            {
                Point pos = GetLocation(e);
                var oLine = GetLineAt(clickPos);
                var cLine = GetLineAt(pos);
                if ( oLine != cLine || cLine == null ) return;
                // find what outlining regions start on the current line
                // if it's one of ours, remove it.
                SnapshotSpan span = new SnapshotSpan(cLine.Start, cLine.End);
                var spans = new NormalizedSnapshotSpanCollection(span);

                foreach ( var tag in tagAggregator.GetTags(spans) ) {
                  if ( !(tag.Tag is OutliningGlyphTag) ) continue;
                  var tagSpan = tag.GetSpan(cLine.Snapshot);
                  if ( tagSpan.IsEmpty ) continue;
                  // we might see tags that cover this region, but
                  // don't start on the selected line
                  if ( TagStartsOnViewLine(tagSpan, cLine) ) {
                RemoveOutlineAt(tagSpan.Start);
                e.Handled = true;
                  }
                  break;
                }
            }
Exemple #30
0
 public static Mock<IMappingSpan> CreateMappingSpan(SnapshotSpan[] spans, MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     var col = new NormalizedSnapshotSpanCollection(spans);
     var mock = factory.Create<IMappingSpan>();
     mock.Setup(x => x.GetSpans(spans[0].Snapshot)).Returns(col);
     mock.Setup(x => x.GetSpans(spans[0].Snapshot.TextBuffer)).Returns(col);
     return mock;
 }