Thank you for reaching out. please find the answer below:
- Use
IVsUIShellOpenDocument.OpenStandardEditor
instead ofDTE.ItemOperations.NewFile
to open a file with your custom editor factory. - Set flags
OSE_UseNewFile
andOSE_OpenAsNewFile
to ensure the file is treated as a new, unsaved, in-memory document. - Use a virtual filename like
"Untitled.sql"
or"inmemory://Untitled.sql"
to avoid creating a physical file on disk. - Provide your custom editor factory’s GUID when calling
OpenStandardEditor
. - Ensure your editor factory is registered using
[ProvideEditorExtension]
or[ProvideEditorFactory]
. - Your editor factory must implement
IVsEditorFactory
and support virtual monikers and theVSEDITOR_CREATE_NEW_FILE
flag. - Use
VSConstants.LOGVIEWID_Primary
as the logical view GUID. - Handle the result with
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hr)
for proper COM error checking. - Call
frame.Show()
to display the editor window once the file is opened. - This method ensures the file is opened entirely in memory and routed through your custom editor, not the default SQL editor.
Let us know if the issue persists after following these steps. We’ll be happy to assist further if needed.