diff options
author | David KarlasĖ <david.karlas@microsoft.com> | 2019-10-16 06:56:13 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2019-10-16 16:14:02 +0300 |
commit | df4015514d77bd21dbc85bb15fccb43e9e92d776 (patch) | |
tree | 0dc91e3ba696f6117a18f24c3b6cc37c55bfc937 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands | |
parent | f8e47aefacc73931c401b6fcc0ac87f79b8b7123 (diff) |
Fix 1002331: Support "Focus Document" commands in new editor
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs index 49aef4fb94..e40db2e70e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs @@ -36,6 +36,8 @@ using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Components.DockNotebook; using System.Collections.Generic; using MonoDevelop.Ide.Gui.Shell; +using Microsoft.VisualStudio.Text.Editor; +using Microsoft.VisualStudio.Text; namespace MonoDevelop.Ide.Commands { @@ -437,29 +439,33 @@ namespace MonoDevelop.Ide.Commands { protected override void Update (CommandInfo info) { - info.Enabled = IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.Editor != null; + info.Enabled = IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.GetContent<ITextView> () != null; } protected override void Run () { IdeApp.Workbench.ActiveDocument.Select (); - IdeApp.Workbench.ActiveDocument.Editor.StartCaretPulseAnimation (); + IdeApp.Workbench.ActiveDocument.Editor?.StartCaretPulseAnimation (); } - } public class CenterAndFocusCurrentDocumentHandler : CommandHandler { protected override void Update (CommandInfo info) { - info.Enabled = IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.Editor != null; + info.Enabled = IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.GetContent<ITextView> () != null; } protected override void Run () { IdeApp.Workbench.ActiveDocument.Select (); - IdeApp.Workbench.ActiveDocument.Editor.CenterToCaret (); - IdeApp.Workbench.ActiveDocument.Editor.StartCaretPulseAnimation (); + if (IdeApp.Workbench.ActiveDocument.Editor != null) { + IdeApp.Workbench.ActiveDocument.Editor.CenterToCaret (); + IdeApp.Workbench.ActiveDocument.Editor.StartCaretPulseAnimation (); + } else { + var textView = IdeApp.Workbench.ActiveDocument.GetContent<ITextView> (); + textView.ViewScroller.EnsureSpanVisible (new SnapshotSpan (textView.Caret.Position.BufferPosition, 0), EnsureSpanVisibleOptions.AlwaysCenter); + } } } } |