private int IndexOfEditableBuffer(ReadOnlyCollection <SnapshotPoint> points, UIThreadOnly uiOnly) { Debug.Assert(_window.OnUIThread()); for (int i = points.Count - 1; i >= 0; i--) { if (IsEditableBuffer(points[i].Snapshot.TextBuffer, uiOnly)) { return(i); } } return(-1); }
public async Task <ExecutionResult> ResetAsync(bool initialize) { try { Debug.Assert(State != State.Resetting, "The button should have been disabled."); if (_window._stdInputStart != null) { CancelStandardInput(); } _window._buffer.Flush(); if (State == State.WaitingForInput) { var snapshot = _window._projectionBuffer.CurrentSnapshot; var spanCount = snapshot.SpanCount; Debug.Assert(_window.GetSpanKind(snapshot.GetSourceSpan(spanCount - 1)) == ReplSpanKind.Language); StoreUncommittedInput(); RemoveProjectionSpans(spanCount - 2, 2); _window._currentLanguageBuffer = null; } State = State.Resetting; var executionResult = await _window._evaluator.ResetAsync(initialize).ConfigureAwait(true); Debug.Assert(_window.OnUIThread()); // ConfigureAwait should bring us back to the UI thread. Debug.Assert(State == State.Resetting, $"Unexpected state {State}"); FinishExecute(executionResult.IsSuccessful); return(executionResult); } catch (Exception e) when(_window.ReportAndPropagateException(e)) { throw ExceptionUtilities.Unreachable; } }