Ejemplo n.º 1
0
        internal void DocumentReopened(ITextDocument document)
        {
            _document = document;

            ITextSnapshot snapshot = document.TextBuffer.CurrentSnapshot;

            SnapshotPoint start;
            SnapshotPoint end;

            if (_useLineIndex)
            {
                start = PersistentSpan.LineIndexToSnapshotPoint(_startLine, _startIndex, snapshot);
                end   = PersistentSpan.LineIndexToSnapshotPoint(_endLine, _endIndex, snapshot);

                if (end < start)
                {
                    //Guard against the case where _start & _end are something like (100,2) & (101, 1).
                    //Those points would pass the argument validation (since _endLine > _startLine) but
                    //would cause problems if the document has only 5 lines since they would map to
                    //(5, 2) & (5, 1).
                    end = start;
                }
            }
            else
            {
                start = new SnapshotPoint(snapshot, Math.Min(_nonTrackingSpan.Start, snapshot.Length));
                end   = new SnapshotPoint(snapshot, Math.Min(_nonTrackingSpan.End, snapshot.Length));
            }

            _span = snapshot.CreateTrackingSpan(new SnapshotSpan(start, end), _trackingMode);

            _filePath = null;
        }
Ejemplo n.º 2
0
        internal PersistentSpan Create(ITextSnapshot snapshot, int startLine, int startIndex, int endLine, int endIndex, SpanTrackingMode trackingMode)
        {
            var start = PersistentSpan.LineIndexToSnapshotPoint(startLine, startIndex, snapshot);
            var end   = PersistentSpan.LineIndexToSnapshotPoint(endLine, endIndex, snapshot);

            if (end < start)
            {
                end = start;
            }

            return(this.Create(new SnapshotSpan(start, end), trackingMode));
        }
        public IPersistentSpan Create(ITextSnapshot snapshot, int startLine, int startIndex, int endLine, int endIndex, SpanTrackingMode trackingMode)
        {
            ITextDocument document;

            if (this.TextDocumentFactoryService.TryGetTextDocument(snapshot.TextBuffer, out document))
            {
                var start = PersistentSpan.LineIndexToSnapshotPoint(startLine, startIndex, snapshot);
                var end   = PersistentSpan.LineIndexToSnapshotPoint(endLine, endIndex, snapshot);
                if (end < start)
                {
                    end = start;
                }

                PersistentSpan persistentSpan = new PersistentSpan(document, new SnapshotSpan(start, end), trackingMode, this);

                this.AddSpan(document, persistentSpan);

                return(persistentSpan);
            }

            return(null);
        }
Ejemplo n.º 4
0
        internal void DocumentReopened()
        {
            ITextSnapshot snapshot = this.SpanSet.Document.TextBuffer.CurrentSnapshot;

            SnapshotPoint start;
            SnapshotPoint end;

            if (_useLineIndex)
            {
                start = PersistentSpan.LineIndexToSnapshotPoint(_startLine, _startIndex, snapshot);
                end   = PersistentSpan.LineIndexToSnapshotPoint(_endLine, _endIndex, snapshot);

                if (end < start)
                {
                    //Guard against the case where _start & _end are something like (100,2) & (101, 1).
                    //Those points would pass the argument validation (since _endLine > _startLine) but
                    //would cause problems if the document has only 5 lines since they would map to
                    //(5, 2) & (5, 1).
                    end = start;
                }
            }
            else
            {
                start = new SnapshotPoint(snapshot, Math.Min(_originalSpan.Start, snapshot.Length));
                end   = new SnapshotPoint(snapshot, Math.Min(_originalSpan.End, snapshot.Length));
            }

            var snapshotSpan = new SnapshotSpan(start, end);

            _span         = snapshot.CreateTrackingSpan(snapshotSpan, _trackingMode);
            _originalSpan = snapshotSpan;

            _originalVersion = snapshot.Version;
            PersistentSpan.SnapshotPointToLineIndex(snapshotSpan.Start, out _startLine, out _startIndex);
            PersistentSpan.SnapshotPointToLineIndex(snapshotSpan.End, out _endLine, out _endIndex);
        }