public override Task Link(params AstNode[] nodes) { var segs = nodes.Select(node => GetSegment(node)).ToArray(); InsertionContext c = new InsertionContext(editor.GetRequiredService <TextArea>(), segs.Min(seg => seg.Offset)); c.InsertionPosition = segs.Max(seg => seg.EndOffset); var tcs = new TaskCompletionSource <bool>(); c.Deactivated += (sender, e) => tcs.SetResult(true); if (segs.Length > 0) { // try to use node in identifier context to avoid the code completion popup. var identifier = nodes.OfType <Identifier>().FirstOrDefault(); ISegment first; if (identifier == null) { first = segs[0]; } else { first = GetSegment(identifier); } c.Link(first, segs.Except(new[] { first }).ToArray()); c.RaiseInsertionCompleted(EventArgs.Empty); } else { c.RaiseInsertionCompleted(EventArgs.Empty); c.Deactivate(new SnippetEventArgs(DeactivateReason.NoActiveElements)); } return(tcs.Task); }
void Deactivate() { if (Element == null) { throw new InvalidOperationException("no IInlineUIElement set!"); } if (deactivated) { return; } deactivated = true; Element.Remove(); context.Deactivate(null); }
protected void Deactivate() { if (Element == null) { throw new InvalidOperationException("no IInlineUIElement set!"); } if (deactivated) { return; } deactivated = true; Element.Remove(); // Cut connection with UndoableInlineDialogCreation undoableCreationOperation.Reset(); insertionContext.Deactivate(null); }