From 1d69a3f23cdfbb616c1d4c8ca3735208895fb766 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 9 May 2022 09:07:23 -0700 Subject: [PATCH] Ensure we do string-copy-paste before format-on-paste --- .../CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs | 6 ++++-- .../Extensibility/Commands/PredefinedCommandHandlerNames.cs | 5 +++++ src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs b/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs index c4c0a52cd5d87..5587df535d02d 100644 --- a/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs +++ b/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs @@ -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; @@ -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. /// [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, IChainedCommandHandler, diff --git a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs index 97d870afb95ff..de1e119d5563a 100644 --- a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs +++ b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs @@ -147,6 +147,11 @@ internal static class PredefinedCommandHandlerNames /// public const string SignatureHelpAfterCompletion = "Signature Help After Completion Command Handler"; + /// + /// Command handler name for String Copy Paste. + /// + public const string StringCopyPaste = "String Copy Paste"; + /// /// Command handler name for Toggle Block Comments. /// diff --git a/src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs b/src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs index 8f1f2991f8719..cfd0f0cb137b3 100644 --- a/src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs +++ b/src/EditorFeatures/Core/Formatting/FormatCommandHandler.cs @@ -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,