diff options
author | Aaron Bockover <abock@microsoft.com> | 2019-02-26 02:29:25 +0300 |
---|---|---|
committer | Aaron Bockover <abock@microsoft.com> | 2019-02-26 03:13:38 +0300 |
commit | 20d8d748d3d4a4742cffd8b1b2b2e568265421fd (patch) | |
tree | 59e86741e6e951abaaf76f976a79771d8eda4d31 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor | |
parent | fffdcfee2ea3a083b66c22a888751d02f08ea0e3 (diff) |
TextEditor: Improve the enable/disable editor UX
When toggling the new editor on or off, if there are files open in
the workbench, offer to close them all.
Hook up the preview commands for disabling the editor, learning more
about the new editor, and reporting issues.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs index 4aa3385876..2c58f9680f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs @@ -32,6 +32,7 @@ using Microsoft.VisualStudio.CodingConventions; using System.Threading.Tasks; using Microsoft.VisualStudio.Text.Editor; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Ide.Editor { @@ -403,8 +404,41 @@ namespace MonoDevelop.Ide.Editor return enableNewEditor; } set { - if (enableNewEditor.Set (value)) - OnChanged (EventArgs.Empty); + if (!enableNewEditor.Set (value)) + return; + + string messageText; + + if (value) { + messageText = GettextCatalog.GetString ( + "The New Editor Preview has been enabled, but already opened files " + + "will need to be closed and re-opened for the change to take effect."); + Counters.NewEditorEnabled.Inc (); + } else { + messageText = GettextCatalog.GetString ( + "The New Editor Preview has been disabled, but already opened files " + + "will need to be closed and re-opened for the change to take effect."); + Counters.NewEditorDisabled.Inc (); + } + + if (IdeApp.Workbench?.Documents?.Count > 0) { + Gtk.Application.Invoke ((o, e) => { + var closeAllFilesButton = new AlertButton (GettextCatalog.GetString ("Close All Files")); + + var message = new MessageDescription { + Text = messageText + }; + + message.Buttons.Add (closeAllFilesButton); + message.Buttons.Add (AlertButton.Ok); + message.DefaultButton = 1; + + if (new AlertDialog (message).Run () == closeAllFilesButton) + IdeApp.Workbench.CloseAllDocumentsAsync (false); + }); + } + + OnChanged (EventArgs.Empty); } } |