提交 8e6daed7 编写于 作者: R RoslynTeam

Interactive window insertion to VS

      Build new VSIX which contains just the interactive window
      Rename interactive window assemblies
      Include new VSIX in the list of files to be inserted

     Public API cleanups
      Move command constants into commands namespace
      Move operations onto IInteractiveWindowOperations interface
      move IContentTypeMetadata to internal class
      Make InteractiveContentTypeNames internal, move constants to InteractiveConstants
      Make RestoreHistoryEditTag internal
      Make CommandIds internal
      Make Guids internal
      Fix AV when opening interactive window
 (changeset 1407857)
上级 16219e30
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow; using Roslyn.Editor.InteractiveWindow;
using Roslyn.Editor.InteractiveWindow.Commands;
namespace Microsoft.CodeAnalysis.Editor.CommandHandlers namespace Microsoft.CodeAnalysis.Editor.CommandHandlers
{ {
[Export] [Export]
[ExportCommandHandler(PredefinedCommandHandlerNames.Completion, InteractiveContentTypeNames.InteractiveCommandContentType)] [ExportCommandHandler(PredefinedCommandHandlerNames.Completion, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)]
[Order(After = PredefinedCommandHandlerNames.SignatureHelp)] [Order(After = PredefinedCommandHandlerNames.SignatureHelp)]
internal sealed class InteractiveCompletionCommandHandler : AbstractCompletionCommandHandler internal sealed class InteractiveCompletionCommandHandler : AbstractCompletionCommandHandler
{ {
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using Roslyn.Editor.InteractiveWindow; using Roslyn.Editor.InteractiveWindow;
using Roslyn.Editor.InteractiveWindow.Commands;
namespace Microsoft.CodeAnalysis.Editor.CommandHandlers namespace Microsoft.CodeAnalysis.Editor.CommandHandlers
{ {
[ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, InteractiveContentTypeNames.InteractiveCommandContentType)] [ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)]
internal sealed class InteractiveIntelliSenseCommandHandler : AbstractIntelliSenseCommandHandler internal sealed class InteractiveIntelliSenseCommandHandler : AbstractIntelliSenseCommandHandler
{ {
[ImportingConstructor] [ImportingConstructor]
......
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow; using Roslyn.Editor.InteractiveWindow;
using Roslyn.Editor.InteractiveWindow.Commands;
namespace Microsoft.CodeAnalysis.Editor.Implementation.Completion.Presentation namespace Microsoft.CodeAnalysis.Editor.Implementation.Completion.Presentation
{ {
[Export(typeof(IIntelliSensePresenter<ICompletionPresenterSession, ICompletionSession>))] [Export(typeof(IIntelliSensePresenter<ICompletionPresenterSession, ICompletionSession>))]
[Export(typeof(ICompletionSourceProvider))] [Export(typeof(ICompletionSourceProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)]
internal partial class CompletionPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter<ICompletionPresenterSession, ICompletionSession>, ICompletionSourceProvider internal partial class CompletionPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter<ICompletionPresenterSession, ICompletionSession>, ICompletionSourceProvider
{ {
private readonly ICompletionBroker _completionBroker; private readonly ICompletionBroker _completionBroker;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis.Interactive; using Microsoft.CodeAnalysis.Interactive;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow; using Roslyn.Editor.InteractiveWindow;
using Roslyn.Editor.InteractiveWindow.Commands;
namespace Microsoft.CodeAnalysis.Editor.Implementation.Interactive namespace Microsoft.CodeAnalysis.Editor.Implementation.Interactive
{ {
...@@ -22,7 +23,7 @@ public InteractiveCommandContentTypeLanguageService(IContentTypeRegistryService ...@@ -22,7 +23,7 @@ public InteractiveCommandContentTypeLanguageService(IContentTypeRegistryService
public IContentType GetDefaultContentType() public IContentType GetDefaultContentType()
{ {
return _contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveCommandContentType); return _contentTypeRegistry.GetContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);
} }
} }
} }
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project> <Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name> <Name>BasicCodeAnalysis</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01e9bd68-0339-4a13-b42f-a3ca84d164f3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Scripting\VisualBasic\BasicScripting.vbproj"> <ProjectReference Include="..\..\..\Scripting\VisualBasic\BasicScripting.vbproj">
<Project>{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}</Project> <Project>{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}</Project>
<Name>BasicScripting</Name> <Name>BasicScripting</Name>
...@@ -62,10 +66,6 @@ ...@@ -62,10 +66,6 @@
<Project>{8E2A252E-A140-45A6-A81A-2652996EA589}</Project> <Project>{8E2A252E-A140-45A6-A81A-2652996EA589}</Project>
<Name>InteractiveFeatures</Name> <Name>InteractiveFeatures</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\EditorFeatures\Text\TextEditorFeatures.csproj"> <ProjectReference Include="..\..\..\EditorFeatures\Text\TextEditorFeatures.csproj">
<Project>{18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}</Project> <Project>{18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}</Project>
<Name>TextEditorFeatures</Name> <Name>TextEditorFeatures</Name>
...@@ -156,4 +156,4 @@ ...@@ -156,4 +156,4 @@
<Import Project="..\..\..\..\build\VSL.Imports.Closed.targets" /> <Import Project="..\..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -11,7 +11,7 @@ internal sealed class ClearScreenCommand : InteractiveWindowCommand ...@@ -11,7 +11,7 @@ internal sealed class ClearScreenCommand : InteractiveWindowCommand
{ {
public override Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments) public override Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments)
{ {
window.ClearView(); window.Operations.ClearView();
return ExecutionResult.Succeeded; return ExecutionResult.Succeeded;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Roslyn.Editor.InteractiveWindow.Commands namespace Roslyn.Editor.InteractiveWindow.Commands
{ {
[Export(typeof(IClassifierProvider))] [Export(typeof(IClassifierProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)]
[TextViewRole(PredefinedTextViewRoles.Document)] [TextViewRole(PredefinedTextViewRoles.Document)]
internal sealed class CommandClassifierProvider : IClassifierProvider internal sealed class CommandClassifierProvider : IClassifierProvider
{ {
......
...@@ -60,7 +60,7 @@ internal Commands(IInteractiveWindow window, string prefix, IEnumerable<IInterac ...@@ -60,7 +60,7 @@ internal Commands(IInteractiveWindow window, string prefix, IEnumerable<IInterac
this.classificationRegistry = classificationRegistry; this.classificationRegistry = classificationRegistry;
if (contentTypeRegistry != null) if (contentTypeRegistry != null)
{ {
this.commandContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveCommandContentType); this.commandContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);
} }
if (window != null) if (window != null)
......
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow.Commands
{
public static class PredefinedInteractiveCommandsContentTypes
{
public const string InteractiveCommandContentTypeName = "Interactive Command";
[Export, Name(InteractiveCommandContentTypeName), BaseDefinition("code")]
internal static readonly ContentTypeDefinition InteractiveCommandContentTypeDefinition;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow
{
internal class ContentTypeMetadata
{
public IEnumerable<string> ContentTypes { get; private set; }
public ContentTypeMetadata(IDictionary<string, object> data)
{
this.ContentTypes = (IEnumerable<string>)data["ContentTypes"];
}
}
}
...@@ -55,21 +55,6 @@ IInteractiveEvaluator Evaluator ...@@ -55,21 +55,6 @@ IInteractiveEvaluator Evaluator
/// <returns>Returns a started task that finishes as soon as the initialization completes.</returns> /// <returns>Returns a started task that finishes as soon as the initialization completes.</returns>
Task<ExecutionResult> InitializeAsync(); Task<ExecutionResult> InitializeAsync();
/// <summary>
/// Clears the REPL window screen.
/// </summary>
void ClearView();
/// <summary>
/// Clears the input history.
/// </summary>
void ClearHistory();
/// <summary>
/// Clears the current input.
/// </summary>
void Cancel();
/// <summary> /// <summary>
/// Closes the underlying text view. /// Closes the underlying text view.
/// </summary> /// </summary>
...@@ -103,11 +88,6 @@ IInteractiveEvaluator Evaluator ...@@ -103,11 +88,6 @@ IInteractiveEvaluator Evaluator
/// </remarks> /// </remarks>
void Submit(IEnumerable<string> inputs); void Submit(IEnumerable<string> inputs);
/// <summary>
/// Resets the execution context clearing all variables.
/// </summary>
Task<ExecutionResult> ResetAsync(bool initialize = true);
/// <summary> /// <summary>
/// Aborts the current command which is executing. /// Aborts the current command which is executing.
/// ///
...@@ -205,40 +185,6 @@ bool IsResetting ...@@ -205,40 +185,6 @@ bool IsResetting
get; get;
} }
/// <summary>
/// Attempts to insert a line break. Returns true if a line break is inserted, false if not.
///
/// Will not submit the input.
/// </summary>
bool BreakLine();
/// <summary>
/// Handles the user pressing return/enter.
///
/// If the caret is at the end of an input submits the current input. Otherwise if the caret is
/// in a language buffer it inserts a newline.
///
/// If not inside of a buffer the caret well be moved to the current language buffer if possible.
///
/// Returns true if the return was successfully processed.
/// </summary>
bool Return();
/// <summary>
/// Executes the current input regardless of the caret position within the input.
///
/// If the caret is in a previously executed input then the input is pasted to the
/// end of the current input and not executed.
/// </summary>
void ExecuteInput();
/// <summary>
/// If the current input is a standard input this will submit the input.
///
/// Returns true if the input was submitted, false otherwise.
/// </summary>
bool TrySubmitStandardInput();
/// <summary> /// <summary>
/// Appends a input into the editor buffer and history as if it has been executed. /// Appends a input into the editor buffer and history as if it has been executed.
/// ///
...@@ -246,74 +192,11 @@ bool IsResetting ...@@ -246,74 +192,11 @@ bool IsResetting
/// </summary> /// </summary>
void AddLogicalInput(string input); void AddLogicalInput(string input);
/// <summary> IInteractiveWindowOperations Operations
/// Advances to the next item in history. {
/// </summary> get;
void HistoryNext(string search = null); }
/// <summary>
/// Advanced to the previous item in history.
/// </summary>
void HistoryPrevious(string search = null);
/// <summary>
/// If no search has been performed captures the current input as
/// the search string. Then searches through history for the next
/// match against the current search string.
/// </summary>
void HistorySearchNext();
/// <summary>
/// If no search has been performed captures the current input as
/// the search string. Then searches through history for the previous
/// match against the current search string.
/// </summary>
void HistorySearchPrevious();
/// <summary>
/// Deletes the current selection or the character before the caret.
/// </summary>
/// <returns></returns>
bool Backspace();
/// <summary>
/// Moves to the beginning of the line.
///
/// When in a language buffer the caret is moved to the beginning of the
/// input region not into the prompt region.
///
/// The caret is moved to the first non-whitespace character.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void Home(bool extendSelection);
/// <summary>
/// Moves to the end of the line.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void End(bool extendSelection);
/// <summary>
/// Selects all of the text in the buffer
/// </summary>
void SelectAll();
/// <summary>
/// Pastes the current clipboard contents into the interactive window.
/// </summary>
/// <returns></returns>
bool Paste();
/// <summary>
/// Cuts the current selection to the clipboard.
/// </summary>
void Cut();
/// <summary>
/// Deletes the current selection.
///
/// Returns true if the selection was deleted
/// </summary>
bool Delete();
} }
} }
using System.Threading.Tasks;
namespace Roslyn.Editor.InteractiveWindow
{
/// <summary>
/// Provides access to low level editor operations on the REPL window.
/// </summary>
public interface IInteractiveWindowOperations
{
/// <summary>
/// Deletes the current selection or the character before the caret.
/// </summary>
/// <returns></returns>
bool Backspace();
/// <summary>
/// Attempts to insert a line break. Returns true if a line break is inserted, false if not.
///
/// Will not submit the input.
/// </summary>
bool BreakLine();
/// <summary>
/// Clears the input history.
/// </summary>
void ClearHistory();
/// <summary>
/// Clears the REPL window screen.
/// </summary>
void ClearView();
/// <summary>
/// Advances to the next item in history.
/// </summary>
void HistoryNext(string search = null);
/// <summary>
/// Advanced to the previous item in history.
/// </summary>
void HistoryPrevious(string search = null);
/// <summary>
/// If no search has been performed captures the current input as
/// the search string. Then searches through history for the next
/// match against the current search string.
/// </summary>
void HistorySearchNext();
/// <summary>
/// If no search has been performed captures the current input as
/// the search string. Then searches through history for the previous
/// match against the current search string.
/// </summary>
void HistorySearchPrevious();
/// <summary>
/// Moves to the beginning of the line.
///
/// When in a language buffer the caret is moved to the beginning of the
/// input region not into the prompt region.
///
/// The caret is moved to the first non-whitespace character.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void Home(bool extendSelection);
/// <summary>
/// Moves to the end of the line.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void End(bool extendSelection);
/// <summary>
/// Selects all of the text in the buffer
/// </summary>
void SelectAll();
/// <summary>
/// Pastes the current clipboard contents into the interactive window.
/// </summary>
/// <returns></returns>
bool Paste();
/// <summary>
/// Cuts the current selection to the clipboard.
/// </summary>
void Cut();
/// <summary>
/// Deletes the current selection.
///
/// Returns true if the selection was deleted
/// </summary>
bool Delete();
/// <summary>
/// Handles the user pressing return/enter.
///
/// If the caret is at the end of an input submits the current input. Otherwise if the caret is
/// in a language buffer it inserts a newline.
///
/// If not inside of a buffer the caret well be moved to the current language buffer if possible.
///
/// Returns true if the return was successfully processed.
/// </summary>
bool Return();
/// <summary>
/// If the current input is a standard input this will submit the input.
///
/// Returns true if the input was submitted, false otherwise.
/// </summary>
bool TrySubmitStandardInput();
/// <summary>
/// Resets the execution context clearing all variables.
/// </summary>
Task<ExecutionResult> ResetAsync(bool initialize = true);
/// <summary>
/// Executes the current input regardless of the caret position within the input.
///
/// If the caret is in a previously executed input then the input is pasted to the
/// end of the current input and not executed.
/// </summary>
void ExecuteInput();
/// <summary>
/// Clears the current input.
/// </summary>
void Cancel();
}
}
\ No newline at end of file
...@@ -3,19 +3,12 @@ ...@@ -3,19 +3,12 @@
namespace Roslyn.Editor.InteractiveWindow namespace Roslyn.Editor.InteractiveWindow
{ {
public static class InteractiveContentTypeNames internal static class InteractiveContentTypeDefinitions
{ {
public const string InteractiveContentType = "Roslyn Interactive"; [Export, Name(PredefinedInteractiveContentTypes.InteractiveContentTypeName), BaseDefinition("text"), BaseDefinition("projection")]
public const string InteractiveOutputContentType = "Roslyn Interactive Output";
public const string InteractiveCommandContentType = "Roslyn Interactive Command";
[Export, Name(InteractiveContentType), BaseDefinition("text"), BaseDefinition("projection")]
internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition; internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition;
[Export, Name(InteractiveOutputContentType), BaseDefinition("text")] [Export, Name(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName), BaseDefinition("text")]
internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition; internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition;
[Export, Name(InteractiveCommandContentType), BaseDefinition("code")]
internal static readonly ContentTypeDefinition InteractiveCommandContentTypeDefinition;
} }
} }
\ No newline at end of file
...@@ -48,6 +48,7 @@ internal class InteractiveWindow : IInteractiveWindow ...@@ -48,6 +48,7 @@ internal class InteractiveWindow : IInteractiveWindow
private readonly IWpfTextView textView; private readonly IWpfTextView textView;
private readonly IEditorOperations editorOperations; private readonly IEditorOperations editorOperations;
private readonly InteractiveOperations interactiveOperations;
private readonly History history; private readonly History history;
private readonly TaskScheduler uiScheduler; private readonly TaskScheduler uiScheduler;
...@@ -142,6 +143,7 @@ internal class InteractiveWindow : IInteractiveWindow ...@@ -142,6 +143,7 @@ internal class InteractiveWindow : IInteractiveWindow
this.host = host; this.host = host;
this.Properties = new PropertyCollection(); this.Properties = new PropertyCollection();
this.history = new History(); this.history = new History();
this.interactiveOperations = new InteractiveOperations(this);
this.projectionBufferFactory = projectionBufferFactory; this.projectionBufferFactory = projectionBufferFactory;
this.bufferFactory = bufferFactory; this.bufferFactory = bufferFactory;
...@@ -152,8 +154,8 @@ internal class InteractiveWindow : IInteractiveWindow ...@@ -152,8 +154,8 @@ internal class InteractiveWindow : IInteractiveWindow
this.smartIndenterService = smartIndenterService; this.smartIndenterService = smartIndenterService;
var textContentType = contentTypeRegistry.GetContentType("text"); var textContentType = contentTypeRegistry.GetContentType("text");
var replContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveContentType); var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName);
var replOutputContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveOutputContentType); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName);
this.outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); this.outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType);
this.stdInputBuffer = bufferFactory.CreateTextBuffer(); this.stdInputBuffer = bufferFactory.CreateTextBuffer();
...@@ -238,7 +240,7 @@ private ITextViewRoleSet CreateRoleSet() ...@@ -238,7 +240,7 @@ private ITextViewRoleSet CreateRoleSet()
PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Editable,
PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Interactive,
PredefinedTextViewRoles.Zoomable, PredefinedTextViewRoles.Zoomable,
InteractiveConstants.InteractiveTextViewRole); PredefinedInteractiveTextViewRoles.InteractiveTextViewRole);
} }
public void Close() public void Close()
...@@ -1188,6 +1190,14 @@ public bool IsResetting ...@@ -1188,6 +1190,14 @@ public bool IsResetting
} }
} }
public IInteractiveWindowOperations Operations
{
get
{
return interactiveOperations;
}
}
public bool Delete() public bool Delete()
{ {
historySearch = null; historySearch = null;
...@@ -1634,7 +1644,7 @@ private string GetActiveCode() ...@@ -1634,7 +1644,7 @@ private string GetActiveCode()
/// <summary> /// <summary>
/// Sets the active code to the specified text w/o executing it. /// Sets the active code to the specified text w/o executing it.
/// </summary> /// </summary>
private void SetActiveCode(string text, object editTag = null) private void SetActiveCode(string text)
{ {
// TODO (tomat): this should be handled by the language intellisense provider, not here: // TODO (tomat): this should be handled by the language intellisense provider, not here:
var completionSession = this.SessionStack.TopSession; var completionSession = this.SessionStack.TopSession;
...@@ -1643,7 +1653,7 @@ private void SetActiveCode(string text, object editTag = null) ...@@ -1643,7 +1653,7 @@ private void SetActiveCode(string text, object editTag = null)
completionSession.Dismiss(); completionSession.Dismiss();
} }
using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: editTag)) using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: null))
{ {
edit.Replace(new Span(0, currentLanguageBuffer.CurrentSnapshot.Length), text); edit.Replace(new Span(0, currentLanguageBuffer.CurrentSnapshot.Length), text);
edit.Apply(); edit.Apply();
...@@ -1656,14 +1666,7 @@ private void SetActiveCode(string text, object editTag = null) ...@@ -1656,14 +1666,7 @@ private void SetActiveCode(string text, object editTag = null)
/// <param name="entry"></param> /// <param name="entry"></param>
private void SetActiveCodeToHistory(History.Entry entry) private void SetActiveCodeToHistory(History.Entry entry)
{ {
object editTag = null; SetActiveCode(entry.Text);
if (entry.OriginalSpan.HasValue)
{
editTag = new RestoreHistoryEditTag(entry.OriginalSpan.Value);
}
SetActiveCode(entry.Text, editTag);
} }
/// <summary> /// <summary>
...@@ -3016,5 +3019,110 @@ internal List<ReplSpan> ProjectionSpans ...@@ -3016,5 +3019,110 @@ internal List<ReplSpan> ProjectionSpans
} }
#endregion #endregion
class InteractiveOperations : IInteractiveWindowOperations
{
private readonly InteractiveWindow window;
public InteractiveOperations(InteractiveWindow window)
{
this.window = window;
}
public bool Backspace()
{
return window.Backspace();
}
public bool BreakLine()
{
return window.BreakLine();
}
public void Cancel()
{
window.Cancel();
}
public void ClearHistory()
{
window.ClearHistory();
}
public void ClearView()
{
window.ClearView();
}
public void Cut()
{
window.Cut();
}
public bool Delete()
{
return window.Delete();
}
public void End(bool extendSelection)
{
window.End(extendSelection);
}
public void ExecuteInput()
{
window.ExecuteInput();
}
public void HistoryNext(string search = null)
{
window.HistoryNext(search);
}
public void HistoryPrevious(string search = null)
{
window.HistoryPrevious(search);
}
public void HistorySearchNext()
{
window.HistorySearchNext();
}
public void HistorySearchPrevious()
{
window.HistorySearchPrevious();
}
public void Home(bool extendSelection)
{
window.Home(extendSelection);
}
public bool Paste()
{
return window.Paste();
}
public Task<ExecutionResult> ResetAsync(bool initialize = true)
{
return window.ResetAsync(initialize);
}
public bool Return()
{
return window.Return();
}
public void SelectAll()
{
window.SelectAll();
}
public bool TrySubmitStandardInput()
{
return window.TrySubmitStandardInput();
}
}
} }
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<ProjectGuid>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</ProjectGuid> <ProjectGuid>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>Roslyn.Editor.InteractiveWindow</RootNamespace> <RootNamespace>Roslyn.Editor.InteractiveWindow</RootNamespace>
<AssemblyName>Roslyn.InteractiveWindow</AssemblyName> <AssemblyName>Microsoft.VisualStudio.InteractiveWindow</AssemblyName>
<!-- TODO --> <!-- TODO -->
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir> <SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<Compile Include="Commands\ClearScreenCommand.cs" /> <Compile Include="Commands\ClearScreenCommand.cs" />
<Compile Include="Commands\CommandClassifier.cs" /> <Compile Include="Commands\CommandClassifier.cs" />
<Compile Include="Commands\CommandClassifierProvider.cs" /> <Compile Include="Commands\CommandClassifierProvider.cs" />
<Compile Include="Commands\PredefinedInteractiveCommandsContentTypes.cs" />
<Compile Include="Commands\InteractiveWindowCommandExtensions.cs" /> <Compile Include="Commands\InteractiveWindowCommandExtensions.cs" />
<Compile Include="Commands\InteractiveWindowCommands.cs" /> <Compile Include="Commands\InteractiveWindowCommands.cs" />
<Compile Include="Commands\HelpCommand.cs" /> <Compile Include="Commands\HelpCommand.cs" />
...@@ -106,7 +107,7 @@ ...@@ -106,7 +107,7 @@
<Compile Include="CustomTrackingSpan.cs" /> <Compile Include="CustomTrackingSpan.cs" />
<Compile Include="ExecutionResult.cs" /> <Compile Include="ExecutionResult.cs" />
<Compile Include="History.cs" /> <Compile Include="History.cs" />
<Compile Include="IContentTypeMetadata.cs" /> <Compile Include="ContentTypeMetadata.cs" />
<Compile Include="Commands\IInteractiveWindowCommands.cs" /> <Compile Include="Commands\IInteractiveWindowCommands.cs" />
<Compile Include="Commands\IInteractiveWindowCommandsFactory.cs" /> <Compile Include="Commands\IInteractiveWindowCommandsFactory.cs" />
<Compile Include="IInteractiveEvaluator.cs" /> <Compile Include="IInteractiveEvaluator.cs" />
...@@ -114,8 +115,9 @@ ...@@ -114,8 +115,9 @@
<Compile Include="IInteractiveWindowEditorFactoryService.cs" /> <Compile Include="IInteractiveWindowEditorFactoryService.cs" />
<Compile Include="IInteractiveWindowFactoryService.cs" /> <Compile Include="IInteractiveWindowFactoryService.cs" />
<Compile Include="Commands\InteractiveCommandsFactory.cs" /> <Compile Include="Commands\InteractiveCommandsFactory.cs" />
<Compile Include="InteractiveConstants.cs" /> <Compile Include="IInteractiveWindowOperations.cs" />
<Compile Include="InteractiveContentTypeNames.cs" /> <Compile Include="PredefinedInteractiveContentTypes.cs" />
<Compile Include="InteractiveContentTypeDefinitions.cs" />
<Compile Include="InteractiveWindow.cs" /> <Compile Include="InteractiveWindow.cs" />
<Compile Include="InteractiveWindowExtensions.cs" /> <Compile Include="InteractiveWindowExtensions.cs" />
<Compile Include="InteractiveWindowOptions.cs" /> <Compile Include="InteractiveWindowOptions.cs" />
...@@ -132,10 +134,10 @@ ...@@ -132,10 +134,10 @@
<Compile Include="Output\ResizingAdorner.cs" /> <Compile Include="Output\ResizingAdorner.cs" />
<Compile Include="Output\SortedSpans.cs" /> <Compile Include="Output\SortedSpans.cs" />
<Compile Include="Output\ZoomableInlineAdornment.cs" /> <Compile Include="Output\ZoomableInlineAdornment.cs" />
<Compile Include="PredefinedInteractiveTextViewRoles.cs" />
<Compile Include="PromptLineMapping.cs" /> <Compile Include="PromptLineMapping.cs" />
<Compile Include="ReplInput.cs" /> <Compile Include="ReplInput.cs" />
<Compile Include="ReplSpanKind.cs" /> <Compile Include="ReplSpanKind.cs" />
<Compile Include="RestoreHistoryEditTag.cs" />
<Compile Include="SmartIndent\InteractiveSmartIndenter.cs" /> <Compile Include="SmartIndent\InteractiveSmartIndenter.cs" />
<Compile Include="SmartIndent\InteractiveSmartIndenterProvider.cs" /> <Compile Include="SmartIndent\InteractiveSmartIndenterProvider.cs" />
<Compile Include="SmartUpDownOption.cs" /> <Compile Include="SmartUpDownOption.cs" />
...@@ -157,4 +159,4 @@ ...@@ -157,4 +159,4 @@
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" /> <Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -12,7 +12,7 @@ namespace Roslyn.Editor.InteractiveWindow ...@@ -12,7 +12,7 @@ namespace Roslyn.Editor.InteractiveWindow
{ {
[Export(typeof(IViewTaggerProvider))] [Export(typeof(IViewTaggerProvider))]
[TagType(typeof(IntraTextAdornmentTag))] [TagType(typeof(IntraTextAdornmentTag))]
[ContentType(InteractiveContentTypeNames.InteractiveContentType)] [ContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName)]
internal sealed class InlineAdornmentProvider : IViewTaggerProvider internal sealed class InlineAdornmentProvider : IViewTaggerProvider
{ {
public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
......
...@@ -15,7 +15,7 @@ namespace Roslyn.Editor.InteractiveWindow ...@@ -15,7 +15,7 @@ namespace Roslyn.Editor.InteractiveWindow
/// Classifies error text in interactive window output. /// Classifies error text in interactive window output.
/// </summary> /// </summary>
[Export(typeof(IClassifierProvider))] [Export(typeof(IClassifierProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveOutputContentType)] [ContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName)]
[TextViewRole(PredefinedTextViewRoles.Document)] [TextViewRole(PredefinedTextViewRoles.Document)]
internal sealed class OutputClassifierProvider : IClassifierProvider internal sealed class OutputClassifierProvider : IClassifierProvider
{ {
......
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow
{
public static class PredefinedInteractiveContentTypes
{
public const string InteractiveContentTypeName = "Interactive Content";
public const string InteractiveOutputContentTypeName = "Interactive Output";
}
}
\ No newline at end of file
using System.ComponentModel.Composition; using System;
using Microsoft.VisualStudio.Utilities; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Roslyn.Editor.InteractiveWindow namespace Roslyn.Editor.InteractiveWindow
{ {
public static class InteractiveConstants public static class PredefinedInteractiveTextViewRoles
{ {
/// <summary> /// <summary>
/// The additional role found in any REPL editor window. /// The additional role found in any REPL editor window.
/// </summary> /// </summary>
public const string InteractiveTextViewRole = "REPL"; public const string InteractiveTextViewRole = "REPL";
} }
} }
\ No newline at end of file
using Microsoft.VisualStudio.Text;
namespace Roslyn.Editor.InteractiveWindow
{
public sealed class RestoreHistoryEditTag
{
/// <summary>
/// The original submission where this history item is from.
/// </summary>
public SnapshotSpan OriginalSpan { get; private set; }
internal RestoreHistoryEditTag(SnapshotSpan originalSpan)
{
OriginalSpan = originalSpan;
}
}
}
...@@ -14,7 +14,7 @@ internal sealed class InteractiveSmartIndenter : ISmartIndent ...@@ -14,7 +14,7 @@ internal sealed class InteractiveSmartIndenter : ISmartIndent
private readonly ISmartIndent indenter; private readonly ISmartIndent indenter;
internal static InteractiveSmartIndenter Create( internal static InteractiveSmartIndenter Create(
IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> smartIndenterProviders, IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> smartIndenterProviders,
IContentType contentType, IContentType contentType,
ITextView view) ITextView view)
{ {
...@@ -55,8 +55,8 @@ public void Dispose() ...@@ -55,8 +55,8 @@ public void Dispose()
// If there are two providers that support the same content type, or // If there are two providers that support the same content type, or
// two providers that support different content types that do not have // two providers that support different content types that do not have
// inheritance relationship, we simply return the first we encounter. // inheritance relationship, we simply return the first we encounter.
private static Tuple<IContentType, Lazy<ISmartIndentProvider, IContentTypeMetadata>> GetProvider( private static Tuple<IContentType, Lazy<ISmartIndentProvider, ContentTypeMetadata>> GetProvider(
IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> smartIndenterProviders, IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> smartIndenterProviders,
IContentType contentType) IContentType contentType)
{ {
// If there are two providers that both support the // If there are two providers that both support the
...@@ -67,7 +67,7 @@ public void Dispose() ...@@ -67,7 +67,7 @@ public void Dispose()
return Tuple.Create(contentType, provider); return Tuple.Create(contentType, provider);
} }
Tuple<IContentType, Lazy<ISmartIndentProvider, IContentTypeMetadata>> bestPair = null; Tuple<IContentType, Lazy<ISmartIndentProvider, ContentTypeMetadata>> bestPair = null;
foreach (var baseType in contentType.BaseTypes) foreach (var baseType in contentType.BaseTypes)
{ {
var pair = GetProvider(smartIndenterProviders, baseType); var pair = GetProvider(smartIndenterProviders, baseType);
......
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
namespace Roslyn.Editor.InteractiveWindow namespace Roslyn.Editor.InteractiveWindow
{ {
[Export(typeof(ISmartIndentProvider))] [Export(typeof(ISmartIndentProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveContentType)] [ContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName)]
internal class InteractiveSmartIndenterProvider : ISmartIndentProvider internal class InteractiveSmartIndenterProvider : ISmartIndentProvider
{ {
private readonly ITextEditorFactoryService editorFactory; private readonly ITextEditorFactoryService editorFactory;
private readonly IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> indentProviders; private readonly IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> indentProviders;
[ImportingConstructor] [ImportingConstructor]
public InteractiveSmartIndenterProvider( public InteractiveSmartIndenterProvider(
ITextEditorFactoryService editorFactory, ITextEditorFactoryService editorFactory,
[ImportMany] IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> indentProviders) [ImportMany] IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> indentProviders)
{ {
if (editorFactory == null) if (editorFactory == null)
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Roslyn.VisualStudio.InteractiveWindow namespace Roslyn.VisualStudio.InteractiveWindow
{ {
public enum CommandIds : uint internal enum CommandIds : uint
{ {
// TODO (crwilcox): should all of these be in the editoroperations? // TODO (crwilcox): should all of these be in the editoroperations?
SmartExecute = 0x103, SmartExecute = 0x103,
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.Utilities;
using Roslyn.Editor.InteractiveWindow;
namespace Roslyn.Editor.InteractiveWindow namespace Microsoft.VisualStudio
{ {
public interface IContentTypeMetadata internal class ContentTypeMetadata
{ {
IEnumerable<string> ContentTypes { get; } public IEnumerable<string> ContentTypes { get; private set; }
public ContentTypeMetadata(IDictionary<string, object> data)
{
this.ContentTypes = (IEnumerable<string>)data["ContentTypes"];
}
} }
public static class ContentTypeMetadataHelpers internal static class ContentTypeMetadataHelpers
{ {
public static T OfContentType<T>( public static T OfContentType<T>(
this IEnumerable<Lazy<T, IContentTypeMetadata>> exports, this IEnumerable<Lazy<T, ContentTypeMetadata>> exports,
IContentType contentType, IContentType contentType,
IContentTypeRegistryService contentTypeRegistry) IContentTypeRegistryService contentTypeRegistry)
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace Roslyn.VisualStudio.InteractiveWindow namespace Roslyn.VisualStudio.InteractiveWindow
{ {
public static class Guids internal static class Guids
{ {
// vsct guids: // vsct guids:
// This GUID identifies the VsInteractiveWindow type. We need to pass it to VS in a string form. // This GUID identifies the VsInteractiveWindow type. We need to pass it to VS in a string form.
......
...@@ -14,11 +14,8 @@ ...@@ -14,11 +14,8 @@
<ProjectGuid>{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}</ProjectGuid> <ProjectGuid>{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<UseCodebase>true</UseCodebase> <UseCodebase>true</UseCodebase>
<!-- This project includes the VS SDK targets so we can produce a .pkgdef, but should not produce a .vsix or anything related to it -->
<CreateVsixContainer>false</CreateVsixContainer>
<DeployExtension>false</DeployExtension>
<RootNamespace>Microsoft.VisualStudio</RootNamespace> <RootNamespace>Microsoft.VisualStudio</RootNamespace>
<AssemblyName>Roslyn.VisualStudio.InteractiveWindow</AssemblyName> <AssemblyName>Microsoft.VisualStudio.VsInteractiveWindow</AssemblyName>
<StartAction>Program</StartAction> <StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram> <StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix RoslynDev /log</StartArguments> <StartArguments>/rootsuffix RoslynDev /log</StartArguments>
...@@ -76,6 +73,7 @@ ...@@ -76,6 +73,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CommandIds.cs" /> <Compile Include="CommandIds.cs" />
<Compile Include="ContentTypeMetadata.cs" />
<Compile Include="Guids.cs" /> <Compile Include="Guids.cs" />
<Compile Include="IVsInteractiveWindowEditorsFactoryService.cs" /> <Compile Include="IVsInteractiveWindowEditorsFactoryService.cs" />
<Compile Include="VsInteractiveWindowEditorFactoryService.cs" /> <Compile Include="VsInteractiveWindowEditorFactoryService.cs" />
...@@ -94,6 +92,9 @@ ...@@ -94,6 +92,9 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>VSInteractiveWindowResources.resx</DependentUpon> <DependentUpon>VSInteractiveWindowResources.resx</DependentUpon>
</Compile> </Compile>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="VSInteractiveWindowResources.resx"> <EmbeddedResource Include="VSInteractiveWindowResources.resx">
...@@ -122,4 +123,4 @@ ...@@ -122,4 +123,4 @@
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" /> <Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -158,7 +158,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -158,7 +158,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
switch ((CommandIds)nCmdID) switch ((CommandIds)nCmdID)
{ {
case CommandIds.BreakLine: case CommandIds.BreakLine:
if (_window.BreakLine()) if (_window.Operations.BreakLine())
{ {
return VSConstants.S_OK; return VSConstants.S_OK;
} }
...@@ -170,7 +170,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -170,7 +170,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
switch ((VSConstants.VSStd2KCmdID)nCmdID) switch ((VSConstants.VSStd2KCmdID)nCmdID)
{ {
case VSConstants.VSStd2KCmdID.RETURN: case VSConstants.VSStd2KCmdID.RETURN:
if (_window.Return()) if (_window.Operations.Return())
{ {
return VSConstants.S_OK; return VSConstants.S_OK;
} }
...@@ -182,7 +182,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -182,7 +182,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
// break; // break;
case VSConstants.VSStd2KCmdID.BACKSPACE: case VSConstants.VSStd2KCmdID.BACKSPACE:
if (_window.Backspace()) if (_window.Operations.Backspace())
{ {
return VSConstants.S_OK; return VSConstants.S_OK;
} }
...@@ -193,7 +193,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -193,7 +193,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown) if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown)
{ {
_window.HistoryPrevious(); _window.Operations.HistoryPrevious();
return VSConstants.S_OK; return VSConstants.S_OK;
} }
break; break;
...@@ -201,7 +201,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -201,7 +201,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
case VSConstants.VSStd2KCmdID.DOWN: case VSConstants.VSStd2KCmdID.DOWN:
if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown) if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown)
{ {
_window.HistoryNext(); _window.Operations.HistoryNext();
return VSConstants.S_OK; return VSConstants.S_OK;
} }
break; break;
...@@ -209,24 +209,24 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -209,24 +209,24 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
case VSConstants.VSStd2KCmdID.CANCEL: case VSConstants.VSStd2KCmdID.CANCEL:
if (_window.TextView.Selection.IsEmpty) if (_window.TextView.Selection.IsEmpty)
{ {
_window.Cancel(); _window.Operations.Cancel();
} }
break; break;
case VSConstants.VSStd2KCmdID.BOL: case VSConstants.VSStd2KCmdID.BOL:
_window.Home(false); _window.Operations.Home(false);
return VSConstants.S_OK; return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.BOL_EXT: case VSConstants.VSStd2KCmdID.BOL_EXT:
_window.Home(true); _window.Operations.Home(true);
return VSConstants.S_OK; return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.EOL: case VSConstants.VSStd2KCmdID.EOL:
_window.End(false); _window.Operations.End(false);
return VSConstants.S_OK; return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.EOL_EXT: case VSConstants.VSStd2KCmdID.EOL_EXT:
_window.End(true); _window.Operations.End(true);
return VSConstants.S_OK; return VSConstants.S_OK;
} }
} }
...@@ -236,22 +236,22 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint ...@@ -236,22 +236,22 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
switch ((VSConstants.VSStd97CmdID)nCmdID) switch ((VSConstants.VSStd97CmdID)nCmdID)
{ {
case VSConstants.VSStd97CmdID.Paste: case VSConstants.VSStd97CmdID.Paste:
_window.Paste(); _window.Operations.Paste();
return VSConstants.S_OK; return VSConstants.S_OK;
case VSConstants.VSStd97CmdID.Cut: case VSConstants.VSStd97CmdID.Cut:
_window.Cut(); _window.Operations.Cut();
return VSConstants.S_OK; return VSConstants.S_OK;
case VSConstants.VSStd97CmdID.Delete: case VSConstants.VSStd97CmdID.Delete:
if (_window.Delete()) if (_window.Operations.Delete())
{ {
return VSConstants.S_OK; return VSConstants.S_OK;
} }
break; break;
case VSConstants.VSStd97CmdID.SelectAll: case VSConstants.VSStd97CmdID.SelectAll:
_window.SelectAll(); _window.Operations.SelectAll();
return VSConstants.S_OK; return VSConstants.S_OK;
} }
} }
...@@ -301,11 +301,15 @@ private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCm ...@@ -301,11 +301,15 @@ private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCm
} }
} }
var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); if (nextTarget != null)
{
var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
#if DUMP_COMMANDS #if DUMP_COMMANDS
//DumpCmd("QS", result, ref pguidCmdGroup, prgCmds[0].cmdID, prgCmds[0].cmdf); //DumpCmd("QS", result, ref pguidCmdGroup, prgCmds[0].cmdID, prgCmds[0].cmdf);
#endif #endif
return result; return result;
}
return VSConstants.E_FAIL;
} }
private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
...@@ -317,16 +321,16 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui ...@@ -317,16 +321,16 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui
switch ((CommandIds)nCmdID) switch ((CommandIds)nCmdID)
{ {
case CommandIds.AbortExecution: _window.AbortCommand(); return VSConstants.S_OK; case CommandIds.AbortExecution: _window.AbortCommand(); return VSConstants.S_OK;
case CommandIds.Reset: _window.ResetAsync(); return VSConstants.S_OK; case CommandIds.Reset: _window.Operations.ResetAsync(); return VSConstants.S_OK;
case CommandIds.SmartExecute: _window.ExecuteInput(); return VSConstants.S_OK; case CommandIds.SmartExecute: _window.Operations.ExecuteInput(); return VSConstants.S_OK;
case CommandIds.HistoryNext: _window.HistoryNext(); return VSConstants.S_OK; case CommandIds.HistoryNext: _window.Operations.HistoryNext(); return VSConstants.S_OK;
case CommandIds.HistoryPrevious: _window.HistoryPrevious(); return VSConstants.S_OK; case CommandIds.HistoryPrevious: _window.Operations.HistoryPrevious(); return VSConstants.S_OK;
case CommandIds.ClearScreen: _window.ClearView(); return VSConstants.S_OK; case CommandIds.ClearScreen: _window.Operations.ClearView(); return VSConstants.S_OK;
case CommandIds.SearchHistoryNext: case CommandIds.SearchHistoryNext:
_window.HistorySearchNext(); _window.Operations.HistorySearchNext();
return VSConstants.S_OK; return VSConstants.S_OK;
case CommandIds.SearchHistoryPrevious: case CommandIds.SearchHistoryPrevious:
_window.HistorySearchPrevious(); _window.Operations.HistorySearchPrevious();
return VSConstants.S_OK; return VSConstants.S_OK;
} }
} }
...@@ -335,11 +339,11 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui ...@@ -335,11 +339,11 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui
switch ((VSConstants.VSStd2KCmdID)nCmdID) switch ((VSConstants.VSStd2KCmdID)nCmdID)
{ {
case VSConstants.VSStd2KCmdID.TYPECHAR: case VSConstants.VSStd2KCmdID.TYPECHAR:
_window.Delete(); _window.Operations.Delete();
break; break;
case VSConstants.VSStd2KCmdID.RETURN: case VSConstants.VSStd2KCmdID.RETURN:
if (_window.TrySubmitStandardInput()) if (_window.Operations.TrySubmitStandardInput())
{ {
return VSConstants.S_OK; return VSConstants.S_OK;
} }
......
...@@ -26,10 +26,10 @@ internal sealed class VsInteractiveWindowEditorFactoryService : IInteractiveWind ...@@ -26,10 +26,10 @@ internal sealed class VsInteractiveWindowEditorFactoryService : IInteractiveWind
private readonly IOleServiceProvider _provider; private readonly IOleServiceProvider _provider;
private readonly IVsEditorAdaptersFactoryService _adapterFactory; private readonly IVsEditorAdaptersFactoryService _adapterFactory;
private readonly IContentTypeRegistryService _contentTypeRegistry; private readonly IContentTypeRegistryService _contentTypeRegistry;
private readonly IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> _oleCommandTargetProviders; private readonly IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> _oleCommandTargetProviders;
[ImportingConstructor] [ImportingConstructor]
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> oleCommandTargetProviders) public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders)
{ {
_adapterFactory = adaptersFactory; _adapterFactory = adaptersFactory;
_provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider)); _provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider));
......
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="1F42C6D0-F876-4AF0-8185-1BEB0A325BB2" Version="|%CurrentProject%;GetBuildVersion|" Language="en-US" Publisher="Microsoft" />
<DisplayName>VisualStudio Interactive Components</DisplayName>
<Description>Interactive components for Visual Studio.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[14.0,]" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VWDExpress" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinExpress" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.VisualStudio.InteractiveWindow.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.VisualStudio.VsInteractiveWindow.dll" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="Microsoft.VisualStudio.VsInteractiveWindow.pkgdef" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="BindingPath.pkgdef" />
</Assets>
</PackageManifest>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册