/// <summary> /// Handles the tab key by calling all registered tab completion handlers. /// </summary> /// <param name="context">Context that can be used to inspect the current command line to perform tab completion</param> public void Handle(RichCommandLineContext context) { context.Intercept = true; context.RefreshTokenInfo(); try { foreach (var handler in TabCompletionHandlers) { if (handler.TryTabComplete(context)) { break; } } } catch (Exception ex) { if (ThrowOnTabCompletionHandlerException) { throw; } else { PowerLogger.LogLine("Tab completion handler threw exception: " + ex.ToString()); } } }
private void DoSyntaxHighlighting(RichCommandLineContext context) { if (Highlighter == null) { return; } bool highlightChanged = false; try { highlightChanged = Highlighter.TryHighlight(context); } catch (Exception ex) { if (ThrowOnSyntaxHighlightException) { throw; } else { PowerLogger.LogLine("Syntax highlighting threw exception: " + ex.ToString()); } } if (highlightChanged) { context.RefreshConsole(0, 0); } }
private void DoSearch(string searchString) { // as soon as this next line runs, any in flight searches become invalid var myRequestId = expireableAsyncRequestManager.BeginRequest(); var backgroundSearchTask = new Task(() => { try { List <ContextAssistSearchResult> results; try { if (SupportsAsync) { var userAsyncTask = GetResultsAsync(searchString); userAsyncTask.Wait(); results = userAsyncTask.Result; } else { results = GetResults(searchString); } } catch (Exception ex) { PowerLogger.LogLine("Exception fetching results on search provider: " + GetType().FullName + "\n\n" + ex); return; } lock (searchReader.SyncLock) { expireableAsyncRequestManager.EndRequest(() => { // this block of code only runs if these results are from the most recent request and // the original called of the search assist still cares about results. selectedIndex = 0; latestResults.Clear(); latestResults.AddRange(results); latestResultsSearchString = searchString; RedrawSearchResults(); }, myRequestId); } }catch (Exception ex) { PowerLogger.LogLine("Background exception is search provider: " + GetType().FullName + "\n\n" + ex); } }); backgroundSearchTask.Start(); }