internal void SetReferenceSpans(IEnumerable <TextSpan> spans)
            {
                AssertIsForeground();

                if (spans.SetEquals(_referenceSpanToLinkedRenameSpanMap.Keys))
                {
                    return;
                }

                using (new SelectionTracking(this))
                {
                    // Revert any previous edits in case we're removing spans.  Undo conflict resolution as well to avoid
                    // handling the various edge cases where a tracking span might not map to the right span in the current snapshot
                    _session.UndoManager.UndoTemporaryEdits(_subjectBuffer, disconnect: false);

                    _referenceSpanToLinkedRenameSpanMap.Clear();
                    foreach (var span in spans)
                    {
                        var document       = _baseDocuments.First();
                        var renameableSpan = _session._renameInfo.GetReferenceEditSpan(
                            new InlineRenameLocation(document, span),
                            GetTriggerText(document, span),
                            CancellationToken.None
                            );
                        var trackingSpan = new RenameTrackingSpan(
                            _subjectBuffer.CurrentSnapshot.CreateTrackingSpan(
                                renameableSpan.ToSpan(),
                                SpanTrackingMode.EdgeInclusive,
                                TrackingFidelityMode.Forward
                                ),
                            RenameSpanKind.Reference
                            );

                        _referenceSpanToLinkedRenameSpanMap[span] = trackingSpan;
                    }

                    _activeSpan =
                        _activeSpan.HasValue && spans.Contains(_activeSpan.Value)
                            ? _activeSpan
                            : spans
                        .Where(
                            s =>
                            // in tests `ActiveTextview` can be null so don't depend on it
                            ActiveTextView == null ||
                            ActiveTextView.GetSpanInView(
                                _subjectBuffer.CurrentSnapshot.GetSpan(s.ToSpan())
                                ).Count != 0
                            )           // spans were successfully projected
                        .FirstOrNull(); // filter to spans that have a projection

                    UpdateReadOnlyRegions();
                    this.ApplyReplacementText(updateSelection: false);
                }

                RaiseSpansChanged();
            }
            internal void SetReferenceSpans(IEnumerable<TextSpan> spans)
            {
                AssertIsForeground();

                if (spans.SetEquals(_referenceSpanToLinkedRenameSpanMap.Keys))
                {
                    return;
                }

                using (new SelectionTracking(this))
                {
                    // Revert any previous edits in case we're removing spans.  Undo conflict resolution as well to avoid 
                    // handling the various edge cases where a tracking span might not map to the right span in the current snapshot
                    _session.UndoManager.UndoTemporaryEdits(_subjectBuffer, disconnect: false);

                    _referenceSpanToLinkedRenameSpanMap.Clear();
                    foreach (var span in spans)
                    {
                        var renameableSpan = _session._renameInfo.GetReferenceEditSpan(
                            new InlineRenameLocation(_baseDocuments.First(), span), CancellationToken.None);
                        var trackingSpan = new RenameTrackingSpan(
                                _subjectBuffer.CurrentSnapshot.CreateTrackingSpan(renameableSpan.ToSpan(), SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward),
                                RenameSpanKind.Reference);

                        _referenceSpanToLinkedRenameSpanMap[span] = trackingSpan;
                    }

                    _activeSpan = _activeSpan.HasValue && spans.Contains(_activeSpan.Value)
                        ? _activeSpan
                        : spans.FirstOrNullable();

                    UpdateReadOnlyRegions();
                    this.ApplyReplacementText(updateSelection: false);
                }

                RaiseSpansChanged();
            }