/// <summary> /// Dismiss the current running completion request /// </summary> private void DismissGetCompletionResults() { try { CommandCompletionHelper.DismissCommandCompletionListRequest(); } catch { ServiceCommon.Log("Failed to stop the existing one."); } }
private void ProcessCompletion(string script, int caretPosition, int requestWindowId, long triggerTag) { lock (_syncLock) { _requestTrigger = triggerTag; } if (_callback == null) { _callback = OperationContext.Current.GetCallbackChannel <IIntelliSenseServiceCallback>(); } // Start process the existing waiting request, should only be one Task.Run(() => { try { CommandCompletion commandCompletion = null; lock (ServiceCommon.RunspaceLock) { if (_runspace.RunspaceAvailability == RunspaceAvailability.Available) { commandCompletion = CommandCompletionHelper.GetCommandCompletionList(script, caretPosition, _runspace); } else { // we'll handle it when we work on giving intellisense for debugging command // for now we just simply return with null for this request to complete. } } ServiceCommon.LogCallbackEvent("Callback intellisense at position {0}", caretPosition); _callback.PushCompletionResult(CompletionResultList.FromCommandCompletion(commandCompletion), requestWindowId); // Reset trigger lock (_syncLock) { _requestTrigger = 0; } } catch (Exception ex) { ServiceCommon.Log("Failed to retrieve the completion list per request due to exception: {0}", ex.Message); } }); }
/// <summary> /// Suspecting this is a powershell bug, the first time you call CommandCompletion.CompleteInput, it takes much longer than usual. /// We are using this dummy call during intializing to warm it up. /// </summary> public void GetDummyCompletionList() { var commandCompletion = CommandCompletionHelper.GetCommandCompletionList("Write-", 6, _runspace); }