提交 836d6a26 编写于 作者: A Artur Spychaj

Merge pull request #9190 from drognanar/fixexecutecommands

[Ask Mode] Fix execute in interactive commands.
......@@ -53,7 +53,7 @@
<Group guid="guidInteractiveWindowCmdSet" id="ConsoleMenuClearGroup" priority="0x300">
<Parent guid="guidInteractiveWindowCmdSet" id="menuIdInteractiveContextMenu"/>
</Group>
<Group guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" priority="0x101">
<Group guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" priority="0x370">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
</Group>
</Groups>
......@@ -231,6 +231,17 @@
-->
<!-- Text editor commands -->
<!-- TODO: Remove once https://github.com/dotnet/roslyn/issues/8927 is done. -->
<Button guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" priority="0x101" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Execute in Interactive</ButtonText>
<CanonicalName>.InteractiveConsole.ExecuteInInteractive</CanonicalName>
<LocCanonicalName>.InteractiveConsole.ExecuteInInteractive</LocCanonicalName>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" priority="0x102" type="Button">
<CommandFlag>DynamicVisibility</CommandFlag>
......@@ -285,7 +296,10 @@
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryPrevious" key1="VK_UP" mod1="Control Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyCode" key1="C" mod1="Control Shift" editor="guidInteractiveWindow" />
<KeyBinding guid="guidVSStd11" id="cmdidExecuteSelectionInInteractive" editor="guidCSharpEditorFactory" mod1="Control" key1="E" mod2="Control" key2="E" />
<!-- TODO: Revert to the code below pending https://github.com/dotnet/roslyn/issues/8927 .
<KeyBinding guid="guidVSStd11" id="cmdidExecuteSelectionInInteractive" editor="guidCSharpEditorFactory" mod1="Control" key1="E" mod2="Control" key2="E" />-->
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="guidCSharpEditorFactory" mod1="Control" key1="E" key2="E" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="guidCSharpEditorFactory" mod1="Control" key1="E" mod2="Control" key2="E" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="K" mod2="Control" key2="VK_RETURN" />
</KeyBindings>
......
......@@ -96,5 +96,10 @@ internal static class Guids
public static readonly Guid RoslynCommandSetId = new Guid(RoslynCommandSetIdString);
public static readonly Guid RoslynGroupId = new Guid(RoslynGroupIdString);
public static readonly Guid RoslynLibraryId = new Guid(RoslynLibraryIdString);
// TODO: Remove pending https://github.com/dotnet/roslyn/issues/8927 .
// Interactive guids
public const string InteractiveCommandSetIdString = "00B8868B-F9F5-4970-A048-410B05508506";
public static readonly Guid InteractiveCommandSetId = new Guid(InteractiveCommandSetIdString);
}
}
......@@ -2,7 +2,7 @@
using System;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Interactive
namespace Microsoft.VisualStudio.LanguageServices
{
internal static partial class ID
{
......@@ -11,6 +11,9 @@ internal static class InteractiveCommands
public const int InteractiveToolWindow = 0x0001;
public const int ResetInteractiveFromProject = 0x0002;
// TODO: Remove pending https://github.com/dotnet/roslyn/issues/8927 .
public const int ExecuteInInteractiveWindow = 0x0010C;
public static readonly string CSharpInteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6";
public static readonly Guid CSharpInteractiveCommandSetId = new Guid(CSharpInteractiveCommandSetIdString);
......
......@@ -47,9 +47,9 @@ public virtual int Exec(ref Guid pguidCmdGroup, uint commandId, uint executeInfo
{
return ExecuteVisualStudio97(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
}
else if (pguidCmdGroup == VSConstants.VsStd11)
else if (pguidCmdGroup == Guids.InteractiveCommandSetId)
{
return ExecuteVisualStudio11(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
return ExecuteInteractive(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
}
else if (pguidCmdGroup == VSConstants.VsStd14)
{
......@@ -570,7 +570,8 @@ private void ExecuteGoToPreviousMethod(ITextBuffer subjectBuffer, IContentType c
lastHandler: executeNextCommandTarget);
}
private int ExecuteVisualStudio11(ref Guid pguidCmdGroup, uint commandId, uint executeInformation, IntPtr pvaIn, IntPtr pvaOut, ITextBuffer subjectBuffer, IContentType contentType)
/// <remarks>TODO: Revert the change to use standard VS11 command pending https://github.com/dotnet/roslyn/issues/8927 .</remarks>
private int ExecuteInteractive(ref Guid pguidCmdGroup, uint commandId, uint executeInformation, IntPtr pvaIn, IntPtr pvaOut, ITextBuffer subjectBuffer, IContentType contentType)
{
int result = VSConstants.S_OK;
var guidCmdGroup = pguidCmdGroup;
......@@ -579,9 +580,9 @@ private int ExecuteVisualStudio11(ref Guid pguidCmdGroup, uint commandId, uint e
result = NextCommandTarget.Exec(ref guidCmdGroup, commandId, executeInformation, pvaIn, pvaOut);
};
switch ((VSConstants.VSStd11CmdID)commandId)
switch (commandId)
{
case VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive:
case ID.InteractiveCommands.ExecuteInInteractiveWindow:
ExecuteExecuteInInteractiveWindow(subjectBuffer, contentType, executeNextCommandTarget);
break;
......
......@@ -37,9 +37,9 @@ public int QueryStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCm
{
return QueryVisualStudio97Status(ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
else if (pguidCmdGroup == VSConstants.VsStd11)
else if (pguidCmdGroup == Guids.InteractiveCommandSetId)
{
return QueryVisualStudio11Status(ref pguidCmdGroup, commandCount, prgCmds, commandText);
return QueryInteractiveStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
else if (pguidCmdGroup == VSConstants.VsStd14)
{
......@@ -224,11 +224,12 @@ private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCoun
}
}
private int QueryVisualStudio11Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
/// <remarks>TODO: Revert the change to use standard VS11 command pending https://github.com/dotnet/roslyn/issues/8927 .</remarks>
private int QueryInteractiveStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
{
switch ((VSConstants.VSStd11CmdID)prgCmds[0].cmdID)
switch (prgCmds[0].cmdID)
{
case VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive:
case ID.InteractiveCommands.ExecuteInInteractiveWindow:
return QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); ;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册