提交 ca8aedce 编写于 作者: N Neal Gafter

Merge branch 'master' of https://github.com/dotnet/roslyn

......@@ -2,13 +2,18 @@
<RuleSet Name="Common diagnostic rules for all non-shipping projects" Description="Enables/disable rules specific to all non-shipping projects." ToolsVersion="14.0">
<Include Path=".\roslyn.ruleset" Action="Default" />
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.CSharp" RuleNamespace="Roslyn.Diagnostics.Analyzers.CSharp">
<!-- For tests, the ConfigureAwait(true) is good enough. Either they are already running on a thread pool
thread where ConfigureAwait(false) does nothing, or we're running the workload from an STA thread
where we want to marshal the continuations back to it. -->
<Rule Id="RS0003" Action="None" />
<Rule Id="RS0007" Action="None" />
</Rules>
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.MetaAnalyzers" RuleNamespace="Roslyn.Diagnostics.Analyzers.MetaAnalyzers">
<Rule Id="RS1001" Action="None" />
</Rules>
<Rules AnalyzerId="Roslyn.Diagnostics.Analyzers.VisualBasic" RuleNamespace="Roslyn.Diagnostics.Analyzers.VisualBasic">
<Rule Id="RS0007" Action="None" />
<!-- See above comment under CSharp -->
<Rule Id="RS0003" Action="None" />
<Rule Id="RS0007" Action="None" />
</Rules>
</RuleSet>
\ No newline at end of file
无法预览此类型文件
......@@ -18,5 +18,10 @@ public interface IInteractiveWindowOperations2 : IInteractiveWindowOperations
/// Line Cut; Cut all selected lines, or the current line if no selection, to the clipboard.
/// </summary>
void CutLine();
/// <summary>
/// Handles character typed in by user.
/// </summary>
void TypeChar(char typedChar);
}
}
......@@ -17,6 +17,8 @@ private sealed class SystemClipboard : InteractiveWindowClipboard
internal override string GetText() => Clipboard.GetText();
internal override void SetDataObject(object data, bool copy) => Clipboard.SetDataObject(data, copy);
internal override IDataObject GetDataObject() => Clipboard.GetDataObject();
}
}
}
......@@ -35,6 +35,21 @@ namespace Microsoft.VisualStudio.InteractiveWindow
internal partial class InteractiveWindow : IInteractiveWindow, IInteractiveWindowOperations2
{
internal const string ClipboardFormat = "89344A36-9821-495A-8255-99A63969F87D";
// The following two field definitions have to stay in sync with VS editor implementation
/// <summary>
/// A data format used to tag the contents of the clipboard so that it's clear
/// the data has been put in the clipboard by our editor
/// </summary>
internal const string ClipboardLineBasedCutCopyTag = "VisualStudioEditorOperationsLineCutCopyClipboardTag";
/// <summary>
/// A data format used to tag the contents of the clipboard as a box selection.
/// This is the same string that was used in VS9 and previous versions.
/// </summary>
internal const string BoxSelectionCutCopyTag = "MSDEVColumnSelect";
internal int LanguageBufferCounter = 0;
public event EventHandler<SubmissionBufferAddedEventArgs> SubmissionBufferAdded;
......@@ -397,6 +412,11 @@ void IInteractiveWindowOperations2.CutLine()
UIThread(uiOnly => uiOnly.CutLine());
}
void IInteractiveWindowOperations2.TypeChar(char typedChar)
{
UIThread(uiOnly => uiOnly.TypeChar(typedChar));
}
#endregion
#region Command Debugging
......@@ -559,12 +579,12 @@ private static void DoEvents()
internal void Undo_TestOnly(int count)
{
UIThread(uiOnly => uiOnly.UndoHistory_TestOnly.Undo(count));
UIThread(uiOnly => uiOnly.UndoHistory?.Undo(count));
}
internal void Redo_TestOnly(int count)
{
UIThread(uiOnly => uiOnly.UndoHistory_TestOnly.Redo(count));
UIThread(uiOnly => uiOnly.UndoHistory?.Redo(count));
}
#endregion
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Windows;
namespace Microsoft.VisualStudio.InteractiveWindow
{
internal abstract class InteractiveWindowClipboard
......@@ -13,5 +15,7 @@ internal abstract class InteractiveWindowClipboard
internal abstract string GetText();
internal abstract void SetDataObject(object data, bool copy);
internal abstract IDataObject GetDataObject();
}
}
......@@ -11,8 +11,8 @@
namespace Microsoft.VisualStudio.InteractiveWindow {
using System;
using System.Reflection;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
......@@ -88,6 +88,24 @@ internal class InteractiveWindowResources {
}
}
/// <summary>
/// Looks up a localized string similar to Delete Character To Left.
/// </summary>
internal static string Backspace {
get {
return ResourceManager.GetString("Backspace", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Insert New Line.
/// </summary>
internal static string BreakLine {
get {
return ResourceManager.GetString("BreakLine", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Clears the contents of the editor window, leaving history and execution context intact..
/// </summary>
......@@ -187,6 +205,42 @@ internal class InteractiveWindowResources {
}
}
/// <summary>
/// Looks up a localized string similar to Cut Selection.
/// </summary>
internal static string Cut {
get {
return ResourceManager.GetString("Cut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cut Line.
/// </summary>
internal static string CutLine {
get {
return ResourceManager.GetString("CutLine", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete Text.
/// </summary>
internal static string Delete {
get {
return ResourceManager.GetString("Delete", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete Line.
/// </summary>
internal static string DeleteLine {
get {
return ResourceManager.GetString("DeleteLine", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to At the end of the current submission, replace the current submission with a subsequent submission (after having previously navigated backwards)..
/// </summary>
......@@ -367,6 +421,15 @@ internal class InteractiveWindowResources {
}
}
/// <summary>
/// Looks up a localized string similar to Insert Text.
/// </summary>
internal static string TypeChar {
get {
return ResourceManager.GetString("TypeChar", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown command &apos;{0}&apos;.
/// </summary>
......
......@@ -225,9 +225,30 @@
<data name="WaitMessage" xml:space="preserve">
<value>Generating Rich Text Format representation from selection.</value>
</data>
<data name="Backspace" xml:space="preserve">
<value>Delete Character To Left</value>
</data>
<data name="BreakLine" xml:space="preserve">
<value>Insert New Line</value>
</data>
<data name="Paste" xml:space="preserve">
<value>Paste</value>
</data>
<data name="Cut" xml:space="preserve">
<value>Cut Selection</value>
</data>
<data name="Delete" xml:space="preserve">
<value>Delete Text</value>
</data>
<data name="CutLine" xml:space="preserve">
<value>Cut Line</value>
</data>
<data name="DeleteLine" xml:space="preserve">
<value>Delete Line</value>
</data>
<data name="TypeChar" xml:space="preserve">
<value>Insert Text</value>
</data>
<data name="CSVBScriptDirectives" xml:space="preserve">
<value>Script directives:</value>
</data>
......
......@@ -87,6 +87,7 @@ Microsoft.VisualStudio.InteractiveWindow.IInteractiveWindowOperations2
Microsoft.VisualStudio.InteractiveWindow.IInteractiveWindowOperations2.Copy() -> void
Microsoft.VisualStudio.InteractiveWindow.IInteractiveWindowOperations2.CutLine() -> void
Microsoft.VisualStudio.InteractiveWindow.IInteractiveWindowOperations2.DeleteLine() -> void
Microsoft.VisualStudio.InteractiveWindow.IInteractiveWindowOperations2.TypeChar(char typedChar) -> void
Microsoft.VisualStudio.InteractiveWindow.InteractiveWindowExtensions
Microsoft.VisualStudio.InteractiveWindow.InteractiveWindowOptions
Microsoft.VisualStudio.InteractiveWindow.PredefinedInteractiveContentTypes
......
......@@ -79,6 +79,7 @@
<Compile Include="HistoryTests.cs" />
<Compile Include="InteractiveWindowHistoryTests.cs" />
<Compile Include="InteractiveWindowTests.cs" />
<Compile Include="InteractiveWindowTests_ClipboardTests.cs" />
<Compile Include="SortedSpansTests.cs" />
<Compile Include="TestClipboard.cs" />
<Compile Include="TestContentTypeDefinition.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Windows;
namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests
......@@ -10,8 +11,6 @@ internal sealed class TestClipboard : InteractiveWindowClipboard
internal void Clear() => _data = null;
internal IDataObject GetDataObject() => _data;
internal override bool ContainsData(string format) => _data?.GetData(format) != null;
internal override object GetData(string format) => _data?.GetData(format);
......@@ -21,5 +20,7 @@ internal sealed class TestClipboard : InteractiveWindowClipboard
internal override string GetText() => _data?.GetText();
internal override void SetDataObject(object data, bool copy) => _data = (DataObject)data;
internal override IDataObject GetDataObject() => _data;
}
}
......@@ -228,12 +228,8 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
// break;
case VSConstants.VSStd2KCmdID.BACKSPACE:
if (_window.Operations.Backspace())
{
return VSConstants.S_OK;
}
break;
_window.Operations.Backspace();
return VSConstants.S_OK;
case VSConstants.VSStd2KCmdID.UP:
......@@ -294,7 +290,6 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
}
}
break;
}
}
else if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
......@@ -326,11 +321,8 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint
break;
case VSConstants.VSStd97CmdID.Delete:
if (_window.Operations.Delete())
{
return VSConstants.S_OK;
}
break;
_window.Operations.Delete();
return VSConstants.S_OK;
case VSConstants.VSStd97CmdID.SelectAll:
_window.Operations.SelectAll();
......@@ -425,8 +417,17 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui
switch ((VSConstants.VSStd2KCmdID)nCmdID)
{
case VSConstants.VSStd2KCmdID.TYPECHAR:
_window.Operations.Delete();
break;
{
var operations = _window.Operations as IInteractiveWindowOperations2;
if (operations != null)
{
char typedChar = (char)(ushort)System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(pvaIn);
operations.TypeChar(typedChar);
return VSConstants.S_OK;
}
_window.Operations.Delete();
break;
}
case VSConstants.VSStd2KCmdID.RETURN:
if (_window.Operations.TrySubmitStandardInput())
......@@ -434,6 +435,7 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui
return VSConstants.S_OK;
}
break;
case VSConstants.VSStd2KCmdID.SHOWCONTEXTMENU:
ShowContextMenu();
return VSConstants.S_OK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册