Skip to content

Commit 1865b5c

Browse files
authored
Merge pull request #56108 from dotnet/merges/main-to-main-vs-deps
Merge main to main-vs-deps
2 parents 9c43caf + f3fe530 commit 1865b5c

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
using Microsoft.VisualStudio.Commanding;
1010
using Microsoft.VisualStudio.Text.Editor;
1111
using Microsoft.VisualStudio.Utilities;
12+
using Microsoft.CodeAnalysis.Notification;
13+
using Microsoft.CodeAnalysis.ErrorReporting;
14+
using Microsoft.CodeAnalysis.Extensions;
1215

1316
#if !COCOA
1417
using System.Linq;
@@ -85,6 +88,38 @@ protected override void SetDashboardFocusToPreviousElement(ITextView textView)
8588
return null;
8689
}
8790
}
91+
92+
protected override void Commit(InlineRenameSession activeSession, ITextView textView)
93+
{
94+
try
95+
{
96+
base.Commit(activeSession, textView);
97+
}
98+
catch (NotSupportedException ex)
99+
{
100+
// Session.Commit can throw if it can't commit
101+
// rename operation.
102+
// handle that case gracefully
103+
var notificationService = activeSession.Workspace.Services.GetService<INotificationService>();
104+
notificationService?.SendNotification(ex.Message, title: EditorFeaturesResources.Rename, severity: NotificationSeverity.Error);
105+
}
106+
catch (Exception ex) when (FatalError.ReportAndCatch(ex))
107+
{
108+
// Show a nice error to the user via an info bar
109+
var errorReportingService = activeSession.Workspace.Services.GetService<IErrorReportingService>();
110+
if (errorReportingService is null)
111+
{
112+
return;
113+
}
114+
115+
errorReportingService.ShowGlobalErrorInfo(
116+
string.Format(EditorFeaturesWpfResources.Error_performing_rename_0, ex.Message),
117+
new InfoBarUI(
118+
WorkspacesResources.Show_Stack_Trace,
119+
InfoBarUI.UIKind.HyperLink,
120+
() => errorReportingService.ShowDetailedErrorInfo(ex), closeAfterAction: true));
121+
}
122+
}
88123
#else
89124
protected override bool DashboardShouldReceiveKeyboardNavigation(ITextView textView)
90125
=> false;

src/EditorFeatures/Core/Implementation/InlineRename/CommandHandlers/AbstractRenameCommandHandler_ReturnHandler.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Diagnostics;
56
using Microsoft.VisualStudio.Commanding;
7+
using Microsoft.VisualStudio.Text.Editor;
68
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
79

810
namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
@@ -20,12 +22,17 @@ public bool ExecuteCommand(ReturnKeyCommandArgs args, CommandExecutionContext co
2022
// InlineRenameSession will call IUIThreadOperationExecutor to sets up our own IUIThreadOperationContext
2123
context.OperationContext.TakeOwnership();
2224

23-
_renameService.ActiveSession.Commit();
24-
SetFocusToTextView(args.TextView);
25+
Commit(_renameService.ActiveSession, args.TextView);
2526
return true;
2627
}
2728

2829
return false;
2930
}
31+
32+
protected virtual void Commit(InlineRenameSession activeSession, ITextView textView)
33+
{
34+
activeSession.Commit();
35+
SetFocusToTextView(textView);
36+
}
3037
}
3138
}

src/VisualStudio/Core/Def/Implementation/Preview/PreviewEngine.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ private static void UpdateTextViewOptions(IWpfTextView textView)
264264

265265
// Do not show LineEndingMargin, which determines EOL and EOF settings.
266266
textView.Options.SetOptionValue(DefaultTextViewHostOptions.LineEndingMarginOptionId, false);
267+
268+
// Do not show the "no issues found" health indicator for previews.
269+
textView.Options.SetOptionValue(DefaultTextViewHostOptions.EnableFileHealthIndicatorOptionId, false);
267270
}
268271

269272
// When the dialog is first instantiated, the IVsTextView it contains may

0 commit comments

Comments
 (0)