Skip to content

Commit

Permalink
Ensure we do string-copy-paste before format-on-paste
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed May 9, 2022
1 parent 40b9280 commit 1d69a3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;
using VSUtilities = Microsoft.VisualStudio.Utilities;

Expand All @@ -43,8 +44,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.StringCopyPaste
/// doesn't want the change we made, they can always undo to get the prior paste behavior.
/// </remarks>
[Export(typeof(ICommandHandler))]
[VSUtilities.ContentType(ContentTypeNames.CSharpContentType)]
[VSUtilities.Name(nameof(StringCopyPasteCommandHandler))]
[ContentType(ContentTypeNames.CSharpContentType)]
[Name(PredefinedCommandHandlerNames.StringCopyPaste)]
[Order(After = PredefinedCommandHandlerNames.FormatDocument)]
internal partial class StringCopyPasteCommandHandler :
IChainedCommandHandler<CutCommandArgs>,
IChainedCommandHandler<CopyCommandArgs>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ internal static class PredefinedCommandHandlerNames
/// </summary>
public const string SignatureHelpAfterCompletion = "Signature Help After Completion Command Handler";

/// <summary>
/// Command handler name for String Copy Paste.
/// </summary>
public const string StringCopyPaste = "String Copy Paste";

/// <summary>
/// Command handler name for Toggle Block Comments.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Microsoft.CodeAnalysis.Formatting
[ContentType(ContentTypeNames.RoslynContentType)]
[Name(PredefinedCommandHandlerNames.FormatDocument)]
[Order(After = PredefinedCommandHandlerNames.Rename)]
[Order(Before = PredefinedCommandHandlerNames.StringCopyPaste)]
[Order(Before = PredefinedCompletionNames.CompletionCommandHandler)]
internal partial class FormatCommandHandler :
ICommandHandler<FormatDocumentCommandArgs>,
Expand Down

0 comments on commit 1d69a3f

Please sign in to comment.