/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.OnItemChosen"]/*' /> public virtual int OnItemChosen(string pszTitle, string pszPath) { TextSpan ts; view.GetCaretPos(out ts.iStartLine, out ts.iStartIndex); ts.iEndLine = ts.iStartLine; ts.iEndIndex = ts.iStartIndex; if (this.expansionSession != null) // previous session should have been ended by now! { EndTemplateEditing(true); } Guid languageSID = this.source.LanguageService.GetType().GUID; // insert the expansion using (CompoundActionBase cab = CompoundActionFactory.GetCompoundAction(this.view, this.source, SR.FormatSpan)) { return(this.vsExpansion.InsertNamedExpansion(pszTitle, pszPath, ts, (IVsExpansionClient)this, languageSID, 0, // fShowDisambiguationUI, (FALSE) out this.expansionSession)); } }
/// <include file='doc\EditArray.uex' path='docs/doc[@for="EditArray.ApplyEdits"]/*' /> public void ApplyEdits() { try { if (this.editList.Count == 0) { return; } if (this.changeCount != this.source.ChangeCount) { throw new InvalidOperationException(SR.GetString(SR.BufferChanged)); } using (this.ca) { Apply(); ca.FlushEditActions(); } this.ca = null; if (this.view != null) { // Update selection. this.view.SetSelection(this.selection.iStartLine, this.selection.iStartIndex, this.selection.iEndLine, this.selection.iEndIndex); this.view.EnsureSpanVisible(this.selection); } } finally { // If compound actions are not null then we need to abort them. Dispose(); } }
private void Dispose(bool disposing) { if (ca != null) { ca.Close(); ca = null; } view = null; source = null; }
/// <include file='doc\EditArray.uex' path='docs/doc[@for="EditArray.EditArray1"]/*' /> /// <summary> /// This constructor takes a view and will use CompoundViewAction to make the updates /// and it will update the current selection accordingly. /// <param name="source">The buffer to operate on</param> /// <param name="view">The text view to use for CompoundViewAction and whose selection you want updated</param> /// <param name="merge">Whether to attempt to merge edits</param> /// <param name="description">Name used in compound action</param> /// </summary> public EditArray(Source source, IVsTextView view, bool merge, string description) { this.source = source; this.editList = new ArrayList(); this.merge = merge; this.description = description; if (view != null) { TextSpan[] pSpan = new TextSpan[1]; view.GetSelectionSpan(pSpan); this.selection = pSpan[0]; this.view = view; } this.ca = CompoundActionFactory.GetCompoundAction(this.view, this.source, description); this.ca.FlushEditActions(); // Sanity check - make sure others are not modifying the buffer while the // caller is preparing the big edit operation. this.changeCount = source.ChangeCount; }