public async void ShowContextActionsFor(Scintilla editor) { var word = editor.GetCurrentWord(); var inlineEdit = editor.GetData <InlineEditData>(0).FirstOrDefault(); var fileId = inlineEdit?.Location.FileId ?? Model.Document.Id; var analytics = await Model.Analyzed; if (analytics.Files.TryGetValue(fileId, out AData.FileDef file)) { var actions = new Dictionary <string, Action>(StringComparer.OrdinalIgnoreCase); void AddSection(string path) { LoadDocument(path, true).Ready.Then(d => { d.Editor.AppendText($"\r\n[{word}]"); }); } if (!file.Sections.ContainsKey(word)) { actions[$"Add Section [{word}]"] = delegate { AddSection(file.FullPath); }; } var filesCanAddSection = analytics.Files.Values.Where(x => !x.Sections.ContainsKey(word)).ToArray(); if (filesCanAddSection.Length > 0) { actions[$"Add Section [{word}] To..."] = delegate { editor.AutoComplete(0, true, filesCanAddSection.ToDictionary(f => $"{Path.GetFileName(f.FullPath)} ({Path.GetDirectoryName(f.FullPath)})", f => f)) .Then(fileToAdd => { AddSection(fileToAdd.FullPath); }); }; } editor.AutoComplete(0, true, actions).Then(x => x()); } }