Share via


IVsAsyncShellOpenDocument.OpenStandardEditorAsync Method

Definition

Opens a file using the standard editor. It will first determine whether a default editor factory for the file is already configured. If a default is not already configured, then it will loop through a priority-sorted list of editor factories to find the first one that supports the document. An exception is thrown if the document cannot be opened.

public Microsoft.VisualStudio.Shell.Interop.IVsTask OpenStandardEditorAsync (uint openStandardEditorFlags, string documentMoniker, Guid logicalView, string? ownerCaption, Microsoft.VisualStudio.Shell.Interop.IVsUIHierarchy? hierarchy, uint itemId, bool shouldGetDocDataFromRdt, object? docData, Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider);
abstract member OpenStandardEditorAsync : uint32 * string * Guid * string * Microsoft.VisualStudio.Shell.Interop.IVsUIHierarchy * uint32 * bool * obj * Microsoft.VisualStudio.OLE.Interop.IServiceProvider -> Microsoft.VisualStudio.Shell.Interop.IVsTask
Public Function OpenStandardEditorAsync (openStandardEditorFlags As UInteger, documentMoniker As String, logicalView As Guid, ownerCaption As String, hierarchy As IVsUIHierarchy, itemId As UInteger, shouldGetDocDataFromRdt As Boolean, docData As Object, serviceProvider As IServiceProvider) As IVsTask

Parameters

openStandardEditorFlags
UInt32

Flags whose values are taken from the __VSOSEFLAGS or __VSOSEFLAGS2 enumeration.

documentMoniker
String

String form of the unique moniker identifier of the document in the project system, for example, the full path to the file. In non-file cases, this identifier is often in the form of a URL.

logicalView
Guid

A Guid identifying the logical view. The default view is VSConstants.LOGVIEWID_Primary and every editor must support that view.

If the editor implements IVsMultiViewDocumentView on the document view object, then the value passed to ActivateLogicalView(Guid), which determines which view is activated when the editor window is shown.

By specifying the logical view Guid, you can request the specific view that matches the reason you are requesting the view. For example, specify VSConstants.LOGVIEWID_Debugging to get the view appropriate for debugging, or VSConstants.LOGVIEWID_TextView to get the view appropriate for the text editor (that is, a view that implements IVsCodeWindow).

ownerCaption
String

Initial caption defined by the document owner (that is, the project) for the document window. This is often of the form: "ProjectName – ItemName."

hierarchy
IVsUIHierarchy

A reference to the IVsUIHierarchy that owns the document.

itemId
UInt32

The UI hierarchy item identifier of the standard editor. For more information see VSConstants.VSITEMID.

shouldGetDocDataFromRdt
Boolean

If true, then the environment will use the doc data object obtained from the Running Document Table; otherwise, the service will open the document using the doc data passed in to docData.

docData
Object

A reference to the document data object of the item to open or null. This value passed into this parameter is ignored if shouldGetDocDataFromRdt is true.

serviceProvider
IServiceProvider

A reference to the IServiceProvider.

Returns

A task representing that the open operation has started. The result of the task is a reference to an IVsAsyncOpenDocumentResult, if the document was opened within the environment; otherwise, null.

Remarks

The task returned by this method does not indicate that the document's view and docdata have been loaded. See DocumentLoadTask for more details.

This method uses the result of CreateEditorInstance(UInt32, String, String, IVsHierarchy, UInt32, IntPtr, IntPtr, IntPtr, String, Guid, Int32) to determine whether it should continue looping to the next editor in the list to find a supported editor factory. Specifically, it should return one of the following: 1. S_OK to indicate that it should stop looping if the editor supports the file and was successfully initialized 2. "VS_E_UNSUPPORTEDFORMAT" to indicate that it should continue looping if the editor does not support the provided doc data 3. Any other error code to indicate that it should stop looping.

This method must be accessed on the main thread.

Applies to