public void SetProjectionMappings(string secondaryContent, IReadOnlyList <ProjectionMapping> mappings) { // Changing projections can move caret to a visible area unexpectedly. // Save caret position so we can place it at the same location when // projections are re-established. SaveViewPosition(); var secondarySpans = CreateSecondarySpans(secondaryContent, mappings); if (IdenticalSpans(secondarySpans)) { return; } // While we are changing mappings map everything to the view mappings = mappings ?? new List <ProjectionMapping>(); MapEverythingToView(); // Now update language spans ContainedLanguageBuffer.ReplaceSpans(0, ContainedLanguageBuffer.CurrentSnapshot.SpanCount, secondarySpans, EditOptions.DefaultMinimalChange, this); if (secondarySpans.Count > 0) { // Update primary (view) buffer projected spans. View buffer spans are all tracking spans: // they either come from primary content or secondary content. Inert spans do not participate. var viewSpans = CreateViewSpans(mappings); if (viewSpans.Count > 0) { ViewBuffer.ReplaceSpans(0, ViewBuffer.CurrentSnapshot.SpanCount, viewSpans, EditOptions.DefaultMinimalChange, this); } } RestoreViewPosition(); MappingsChanged?.Invoke(this, EventArgs.Empty); }
async void RaiseMappingsChangedAsync() { if (MappingsChanged != null) { await new ThreadSwitcher(); MappingsChanged.Invoke(this, EventArgs.Empty); } }
async void RaiseMappingsChangedAsync() { if (MappingsChanged != null) { await MainLoop.SwitchThread(); MappingsChanged.Invoke(this, EventArgs.Empty); } }
async void RaiseMappingsChangedAsync() { if (MappingsChanged == null) { return; } await MainLoop.SwitchToThreadpool(); MappingsChanged?.Invoke(this, EventArgs.Empty); }
private static void RaiseMappingsChangedEvent() { PopulateMappingLists(); SaveMappings(); MappingsChanged?.Invoke(null, null); }