protected override IEnumerable <IResult> GetResults(IQuery query) { if (query.Text.Length < 3) { return(Enumerable.Empty <IResult>()); } var m = new MultiWordMatch(query); return(System.Environment.GetEnvironmentVariables() .Cast <DictionaryEntry>() .Where(_ => m.IsMatch(((string)_.Key))) .Select(_ => new SimpleAction( context.LastExecutedStore, _.Key.ToString(), $"#environment {_.Key}={_.Value}", () => { context.InsertText(_.Value.ToString()); }).ToResult(query))); }
protected override IEnumerable <IResult> GetResults(IQuery query) { if (!query.Tags.Any() && query.Text.Length < 2) { return(Enumerable.Empty <IResult>()); } var all = new[] { "notes", "help" }.Any(_ => query.Text.Equals(_, StringComparison.CurrentCultureIgnoreCase)); if (all) { return(notes .Select(_ => new NoteAction(_, query.Context.LastExecutedStore)) .Select(_ => _.ToResult(Priority.Normal))); } var terms = Tokenizer.ToList(query.Text.OneLine(80)); var re = new MultiWordMatch(query); return(notes.Where(n => re.IsMatch(n.Name)) .Select(_ => new NoteAction(_, query.Context.LastExecutedStore)) .Select(_ => _.ToResult(GetPriority(_, terms)))); }