diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2019-03-21 00:29:49 +0300 |
---|---|---|
committer | Lluis Sanchez <llsan@microsoft.com> | 2019-03-21 00:29:49 +0300 |
commit | 228695e2dc646fb2ad812c06bebfe33ca9f69601 (patch) | |
tree | 89a6f3a75447bc4a202add057b05fb67b68ac762 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands | |
parent | 935f47982ef658566f1b1af36acdd5ca46cdb323 (diff) | |
parent | b14cae42f57650e9de2dd31d1beab5f90a4d44ec (diff) |
Merge remote-tracking branch 'xamarin/master-vnext' into new-service-model
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands')
4 files changed, 75 insertions, 55 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs index 681c3c749f..06569171bd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs @@ -1,41 +1,41 @@ -// CustomStringTagProvider.cs -// -// Author: -// Viktoria Dudka (viktoriad@remobjects.com) -// -// Copyright (c) 2009 RemObjects Software -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// - - +// CustomStringTagProvider.cs
+//
+// Author:
+// Viktoria Dudka (viktoriad@remobjects.com)
+//
+// Copyright (c) 2009 RemObjects Software
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+
using System; -using MonoDevelop.Core; -using MonoDevelop.Ide.Gui; -using System.IO; using System.Collections.Generic; +using Microsoft.VisualStudio.Text.Editor;
+using MonoDevelop.Core; using MonoDevelop.Core.StringParsing; - +using MonoDevelop.Ide.Gui; +
namespace MonoDevelop.Ide.Commands -{ - // The path name should not be required here. This is a workaround to a Mono.Addins bug (fixed in the last version) +{
+ // The path name should not be required here. This is a workaround to a Mono.Addins bug (fixed in the last version)
[Mono.Addins.Extension ("/MonoDevelop.Core/TypeExtensions/MonoDevelop.Core.StringParsing.IStringTagProvider")] class DefaultStringTagProvider : StringTagProvider<Workbench> { @@ -85,30 +85,43 @@ namespace MonoDevelop.Ide.Commands return !wb.ActiveDocument.IsFile ? String.Empty : wb.ActiveDocument.FileName.Extension; return null; - case "CURLINE": - if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null) - return wb.ActiveDocument.Editor.CaretLocation.Line; + case "CURLINE": {
+ if (wb.ActiveDocument?.GetContent<ITextView> () is ITextView view) {
+ var pos = view.Caret.Position.BufferPosition; + return pos.Snapshot.GetLineNumberFromPosition (pos.Position) + 1;
+ } return null; + } - case "CURCOLUMN": - if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null) - return wb.ActiveDocument.Editor.CaretLocation.Column; - return null; + case "CURCOLUMN": {
+ if (wb.ActiveDocument?.GetContent<ITextView> () is ITextView view) {
+ var pos = view.Caret.Position.BufferPosition; + var line = pos.Snapshot.GetLineFromPosition (pos.Position); + return pos.Position - line.Start.Position + 1;
+ }
+ return null;
+ } - case "CUROFFSET": - if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null) - return wb.ActiveDocument.Editor.CaretOffset; - return null; + case "CUROFFSET": {
+ if (wb.ActiveDocument?.GetContent<ITextView> () is ITextView view) {
+ return view.Caret.Position.BufferPosition.Position;
+ }
+ return null;
+ } - case "CURTEXT": - if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null) - return wb.ActiveDocument.Editor.SelectedText; + case "CURTEXT": {
+ if (wb.ActiveDocument?.GetContent<ITextView> () is ITextView view) {
+ return view.Selection.IsEmpty? "" : view.Selection.SelectedSpans[0].GetText ();
+ } return null; + } - case "EDITORTEXT": - if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null) - return wb.ActiveDocument.Editor.Text; + case "EDITORTEXT": {
+ if (wb.ActiveDocument?.GetContent<ITextView> () is ITextView view) {
+ return view.TextBuffer.CurrentSnapshot.GetText ();
+ } return null; + } case "STARTUPPATH": return AppDomain.CurrentDomain.BaseDirectory; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs index a3ad7cc5d6..cc7c2f51c9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs @@ -33,7 +33,8 @@ using Mono.Addins; using MonoDevelop.Components.Commands; using MonoDevelop.Ide.Gui; using MonoDevelop.Projects; - +using Microsoft.VisualStudio.Text.Editor;
+
namespace MonoDevelop.Ide.Commands { public enum EditCommands @@ -357,13 +358,13 @@ namespace MonoDevelop.Ide.Commands { Document doc = IdeApp.Workbench.ActiveDocument; string header = MonoDevelop.Ide.StandardHeader.StandardHeaderService.GetHeader (doc.Owner as SolutionFolderItem, doc.Name, false); - doc.Editor.InsertText (0, header + "\n"); + doc.GetContent<ITextView> ().TextBuffer.Insert (0, header + "\n"); } protected override void Update (CommandInfo info) { Document doc = IdeApp.Workbench.ActiveDocument; - if (doc != null && doc.Editor != null) { + if (doc?.GetContent<ITextView> () is ITextView) { info.Enabled = doc.CommentTags != null; } else info.Enabled = false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs index 4cdba68607..9a215e95b8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs @@ -65,6 +65,12 @@ namespace MonoDevelop.Ide.Commands // MonoDevelop.Ide.Commands.HelpCommands.OpenLogDirectory public class OpenLogDirectoryHandler : CommandHandler { + protected override void Update (CommandInfo info) + { + info.DisableOnShellLock = false; + info.Enabled = true; + } + protected override void Run () { try { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs index d54a310855..6574f834e0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs @@ -104,7 +104,7 @@ namespace MonoDevelop.Ide.Commands protected override void Run () { - IdeApp.Workbench.ShowGlobalPreferencesDialog (IdeApp.Workbench.RootWindow, "ExternalTools"); + IdeApp.Workbench.ShowGlobalPreferencesDialog (DesktopService.GetFocusedTopLevelWindow (), "ExternalTools"); } } |