-
Notifications
You must be signed in to change notification settings - Fork 356
Change the command to raise when adding new project from existing code #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👍 |
Thanks for figuring this out! Now you are calling AddProject instead of OpenProject, I can see how this fixes the issue referenced. Did you also check that running the "Import from existing code" scenario with no existing project/sln open still continues to work also? |
Right, after some tests it didn't work for the no-existing project/sln scenario. I need to fix that. |
@billti Added code to detect the availability of the "Add Existing Project", now it works as expected in both cases. |
@@ -81,7 +81,15 @@ class ImportWizardCommand : Command { | |||
} | |||
if (File.Exists(path)) { | |||
object outRef = null, pathRef = "\"" + path + "\""; | |||
NodejsPackage.Instance.DTE.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString("B"), (int)VSConstants.VSStd97CmdID.OpenProject, ref pathRef, ref outRef); | |||
var addExistingProjectCmd = NodejsPackage.Instance.DTE.Commands.Item("File.AddExistingProject"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work in the instance where a project is open (so the AddExistingProject command is available), but someone is nonetheless creating a new project?
Perhaps a better solution is to intercept the command in the NodejsPackage.Initialize() step by handling BeforeExecute and AfterExecute events (set a boolean flag that we check in ImportWizardCommand).
E.g. http://stackoverflow.com/questions/15406523/visual-studio-extensibility-intercepting-file-paste-event
} | ||
else { | ||
NodejsPackage.Instance.DTE.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString("B"), (int)VSConstants.VSStd97CmdID.OpenProject, ref pathRef, ref outRef); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, just pass in the cmdIdToRaise rather than effectively checking it twice.
Then, you can can simplify all this to:
NodejsPackage.Instance.DTE.Commands.Raise(
VSConstants.GUID_VSStandardCommandSet97.ToString("B"), cmdIdToRaise, ref pathRef, ref outRef);
Overall implementation looks good now - left several minor comments and lgtm after that. |
@mousetraps can you take a look at my updates? Thanks! |
👍 |
Fix #133 - Change the command to raise when adding new project from existing code
This PR fixes #133.
Previously the raised command when adding new project from existing code is
VSConstants.VSStd97CmdID.OpenProject
, which actually corresponds to theOpen Project
menu item, that will always create a new solution. Changing it toVSConstants.VSStd97CmdID.AddExistingProject
fixed the problem.