Partager via


IVsLinkedUndoTransactionManager.OpenLinkedUndo(UInt32, String) Method

Definition

Opens a linked undo transaction parent unit.

public:
 int OpenLinkedUndo(System::UInt32 dwFlags, System::String ^ pszDescription);
public:
 int OpenLinkedUndo(unsigned int dwFlags, Platform::String ^ pszDescription);
int OpenLinkedUndo(unsigned int dwFlags, std::wstring const & pszDescription);
public int OpenLinkedUndo (uint dwFlags, string pszDescription);
abstract member OpenLinkedUndo : uint32 * string -> int
Public Function OpenLinkedUndo (dwFlags As UInteger, pszDescription As String) As Integer

Parameters

dwFlags
UInt32

[in] Value taken from the LinkedTransactionFlags enumeration. mdtDefault specifies the transaction to be nonstrict, which is default behavior. The other possible enum values are mdtStrict which specifies the undo linking behavior as strict, and mdtGlobal, which specifies the undo linking behavior as global. For more information, see the Remarks section later in this topic.

pszDescription
String

[in] Localized string that describes this action; appears in the undo/redo dropdown menus. This value may not be null.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

From textmgr.idl:

HRESULT IVsLinkedUndoTransactionManager::OpenLinkedUndo(

[in] DWORD dwFlags,

[in] const WCHAR *pszDescription

);

  • Nonstrict linked undo behavior (mdtDefault) means that some of the documents with linked undo siblings can close and still leave the other linked undo siblings on their stacks. An example of nonstrict undo behavior is found in the Microsoft Office suite. Microsoft Word allows one file to close during a drag-and-drop operation in such a way that one file loses information.

  • Strict linked undo behavior specifies that all the linked undo sibling stacks have to be undone together or not at all. A strict linked undo operation (mdtStrict) is usually necessary in editorial changes that involve simultaneous text changes across multiple program files, such as a header file and a Visual C++ file. This is, in fact, the model used in Visual Studio.

  • A global undo operation (mdtGlobal) is a strict undo behavior as well, the only difference being that the affected documents need not be open in the Visual Studio IDE to have their changes reversed. One example of this is if you were to undo a Rename refactoring operation on a variable name in a project. The undo reverts the rename changes in all affected documents of the project, regardless of whether they are currently open in the IDE.

    Any buffer that is opened (but not necessarily changed) during an mdtGlobal undo transaction is flagged as a buffer that participates in the global buffer undo operation. The undo stacks of those buffers (documents) are preserved if the buffers are closed and then reopened again in the same IDE session.

To enable global undo when creating your own implementation of IVsPersistDocData2 — using a VsTextBuffer as a buffer for your implementation of DocData — be sure to site the DocData properly by calling SetSite with a valid service provider. In addition, you must call OnRegisterDocData on your VsTextBuffer.

Applies to