diff options
author | David KarlasĖ <david.karlas@microsoft.com> | 2019-05-29 13:41:33 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2020-01-10 11:49:21 +0300 |
commit | 28fb09b1817f312005183250c0475824182f271e (patch) | |
tree | fe61c30b3ed2916dfc55eb05563c7bf96fd5cc36 /main | |
parent | c61aae69526e98262c8f7a684fd54330c8f6f278 (diff) |
Fix 822175: Exception adornment scrolled outside of view Only reasonable fix is to follow VS Windows way of displaying it as window because things get tricky with wrapped view where you can't just expand text view scrollable width...
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs index 6a633f99d0..84f868b0a7 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs @@ -43,6 +43,7 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught private readonly string filePath; readonly IXPlatAdornmentLayer _exceptionCaughtLayer; FileLineExtension extension; + NSWindow exceptionCaughtButtonWindow; public ExceptionCaughtAdornmentManager (ICocoaViewFactory cocoaViewFactory, ICocoaTextView textView) { @@ -68,6 +69,10 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught if (e.Extension == extension) { extension = null; _exceptionCaughtLayer.RemoveAllAdornments (); + if (exceptionCaughtButtonWindow != null) { + exceptionCaughtButtonWindow.Close (); + exceptionCaughtButtonWindow = null; + } } } @@ -81,11 +86,14 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught private void RenderAdornment (FileLineExtension fileLineExtension) { NSView view; - if (fileLineExtension is ExceptionCaughtButton button) + bool mini; + if (fileLineExtension is ExceptionCaughtButton button) { + mini = false; view = CreateButton (cocoaViewFactory, button); - else if (fileLineExtension is ExceptionCaughtMiniButton miniButton) + } else if (fileLineExtension is ExceptionCaughtMiniButton miniButton) { + mini = true; view = CreateMiniButton (cocoaViewFactory, miniButton); - else + } else return; if (extension != fileLineExtension) { extension = fileLineExtension; @@ -97,17 +105,37 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught return; if (!textView.TextViewLines.FormattedSpan.Contains (span.End)) return; - try { - var charBound = textView.TextViewLines.GetCharacterBounds (span.End); - view.SetFrameOrigin (new CGPoint ( + _exceptionCaughtLayer.RemoveAllAdornments (); + if (exceptionCaughtButtonWindow != null) { + exceptionCaughtButtonWindow.Close (); + exceptionCaughtButtonWindow = null; + } + var charBound = textView.TextViewLines.GetCharacterBounds (span.End); + if (mini) { + try { + view.SetFrameOrigin (new CGPoint ( Math.Round (charBound.Left), - Math.Round (charBound.TextTop + charBound.TextHeight / 2 - view.Frame.Height / 2))); - } catch (Exception e) { - view.SetFrameOrigin (default); - LoggingService.LogInternalError ("https://vsmac.dev/923058", e); + Math.Round (charBound.TextTop - charBound.TextHeight / 2 - view.Frame.Height / 2))); + } catch (Exception e) { + view.SetFrameOrigin (default); + LoggingService.LogInternalError ("https://vsmac.dev/923058", e); + } + _exceptionCaughtLayer.AddAdornment (XPlatAdornmentPositioningBehavior.TextRelative, span, null, view, null); + } else { + var editorWindow = textView.VisualElement.Window; + var pointOnScreen = editorWindow.ConvertPointToScreen (textView.VisualElement.ConvertPointToView (new CGPoint (charBound.Left, charBound.TextTop), null)); + exceptionCaughtButtonWindow = new NSWindow (CGRect.Empty, NSWindowStyle.Borderless, NSBackingStore.Buffered, false); + editorWindow.AddChildWindow (exceptionCaughtButtonWindow, NSWindowOrderingMode.Above); + exceptionCaughtButtonWindow.IsOpaque = false; + exceptionCaughtButtonWindow.BackgroundColor = NSColor.Clear; + exceptionCaughtButtonWindow.HasShadow = true; + exceptionCaughtButtonWindow.ContentView = view; + var fittingSize = view.FittingSize; + var x = Math.Min (editorWindow.Screen.VisibleFrame.Width - fittingSize.Width, pointOnScreen.X); + var y = Math.Max (0, pointOnScreen.Y - fittingSize.Height / 2); + exceptionCaughtButtonWindow.SetFrame (new CGRect (x, y, fittingSize.Width, fittingSize.Height), true); + exceptionCaughtButtonWindow.MakeKeyAndOrderFront (null); } - _exceptionCaughtLayer.RemoveAllAdornments (); - _exceptionCaughtLayer.AddAdornment (XPlatAdornmentPositioningBehavior.TextRelative, span, null, view, null); } private void TextView_LayoutChanged (object sender, TextViewLayoutChangedEventArgs e) |