private void RSession_AfterRequest(object sender, RRequestEventArgs e) { bool?sentContinue; lock (_browseLock) { var browseEventArgs = _currentBrowseEventArgs; if (browseEventArgs == null || browseEventArgs.Contexts != e.Contexts) { // This AfterRequest does not correspond to a Browse prompt, or at least not one // that we have seen before (and paused on), so there's nothing to do. return; } _currentBrowseEventArgs = null; sentContinue = _sentContinue; _sentContinue = true; } if (sentContinue == false) { // User has explicitly typed something at the Browse prompt, so tell the debugger that // we're moving on by issuing a dummy Continue request to switch it to the running state. var vsShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); Guid group = VSConstants.GUID_VSStandardCommandSet97; object arg = null; var ex = Marshal.GetExceptionForHR(vsShell.PostExecCommand(ref group, (uint)VSConstants.VSStd97CmdID.Start, 0, ref arg)); Trace.Assert(ex == null); } }
async Task <string> IRCallbacks.ReadConsole(IReadOnlyList <IRContext> contexts, string prompt, int len, bool addToHistory, bool isEvaluationAllowed, CancellationToken ct) { await TaskUtilities.SwitchToBackgroundThread(); var currentRequest = Interlocked.Exchange(ref _currentRequestSource, null); _contexts = contexts; Prompt = prompt; MaxLength = len; var requestEventArgs = new RRequestEventArgs(contexts, prompt, len, addToHistory); BeforeRequest?.Invoke(this, requestEventArgs); CancellationTokenSource evaluationCts; Task evaluationTask; if (isEvaluationAllowed) { evaluationCts = new CancellationTokenSource(); evaluationTask = EvaluateUntilCancelled(contexts, evaluationCts.Token, ct); // will raise Mutate } else { evaluationCts = null; evaluationTask = Task.CompletedTask; OnMutated(); } currentRequest?.CompleteResponse(); string consoleInput = null; do { ct.ThrowIfCancellationRequested(); try { consoleInput = await ReadNextRequest(prompt, len, ct); } catch (OperationCanceledException) { // If request was canceled through means other than our token, it indicates the refusal of // that requestor to respond to that particular prompt, so move on to the next requestor. // If it was canceled through the token, then host itself is shutting down, and cancellation // will be propagated on the entry to next iteration of this loop. } } while (consoleInput == null); // If evaluation was allowed, cancel evaluation processing but await evaluation that is in progress evaluationCts?.Cancel(); await evaluationTask; AfterRequest?.Invoke(this, requestEventArgs); return(consoleInput); }
private void SessionOnBeforeRequest(object sender, RRequestEventArgs e) { _coreShell.DispatchOnUIThread(() => { if (CurrentWindow == null || CurrentWindow.IsRunning) { return; } var projectionBuffer = CurrentWindow.TextView.TextBuffer as IProjectionBuffer; if (projectionBuffer == null) { return; } var spanCount = projectionBuffer.CurrentSnapshot.SpanCount; projectionBuffer.ReplaceSpans(spanCount - 2, 1, new List <object> { GetPrompt() }, EditOptions.None, new object()); }); }
private void RSession_BeforeRequest(object sender, RRequestEventArgs e) { ResetStackFrames(); }
async Task<string> IRCallbacks.ReadConsole(IReadOnlyList<IRContext> contexts, string prompt, int len, bool addToHistory, bool isEvaluationAllowed, CancellationToken ct) { await TaskUtilities.SwitchToBackgroundThread(); var currentRequest = Interlocked.Exchange(ref _currentRequestSource, null); _contexts = contexts; Prompt = prompt; MaxLength = len; var requestEventArgs = new RRequestEventArgs(contexts, prompt, len, addToHistory); BeforeRequest?.Invoke(this, requestEventArgs); CancellationTokenSource evaluationCts; Task evaluationTask; if (isEvaluationAllowed) { evaluationCts = new CancellationTokenSource(); evaluationTask = EvaluateUntilCancelled(contexts, evaluationCts.Token, ct); // will raise Mutate } else { evaluationCts = null; evaluationTask = Task.CompletedTask; OnMutated(); } currentRequest?.CompleteResponse(); string consoleInput = null; do { ct.ThrowIfCancellationRequested(); try { consoleInput = await ReadNextRequest(prompt, len, ct); } catch (OperationCanceledException) { // If request was canceled through means other than our token, it indicates the refusal of // that requestor to respond to that particular prompt, so move on to the next requestor. // If it was canceled through the token, then host itself is shutting down, and cancellation // will be propagated on the entry to next iteration of this loop. } } while (consoleInput == null); // If evaluation was allowed, cancel evaluation processing but await evaluation that is in progress evaluationCts?.Cancel(); await evaluationTask; AfterRequest?.Invoke(this, requestEventArgs); return consoleInput; }
private void RSession_AfterRequest(object sender, RRequestEventArgs e) { _currentBrowseEventArgs = null; }
private void RSession_BeforeRequest(object sender, RRequestEventArgs e) { _initialPromptCts.Cancel(); ProcessBrowsePrompt(e.Contexts); }
private void OnAfterRequest(object sender, RRequestEventArgs e) { _enabled = true; }
private void OnBeforeRequest(object sender, RRequestEventArgs e) { _enabled = e.Contexts.Count != 1; // Disable command only if prompt is in the top level }