diff --git a/ShowInGithub/Properties/AddinInfo.cs b/ShowInGithub/Properties/AddinInfo.cs index 6cba502..8992420 100644 --- a/ShowInGithub/Properties/AddinInfo.cs +++ b/ShowInGithub/Properties/AddinInfo.cs @@ -5,7 +5,7 @@ [assembly:Addin ( "ShowInGithub", Namespace = "ShowInGithub", - Version = "1.0.4" + Version = "1.0.5" )] [assembly:AddinName ("Show in Github")] diff --git a/ShowInGithub/Properties/AssemblyInfo.cs b/ShowInGithub/Properties/AssemblyInfo.cs deleted file mode 100644 index e393db5..0000000 --- a/ShowInGithub/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle ("ShowInGithub")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("Xamarin")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Xamarin, Inc (http://www.xamarin.com)")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion ("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/ShowInGithub/Properties/Manifest.addin.xml b/ShowInGithub/Properties/Manifest.addin.xml index 2efc7b2..b217397 100644 --- a/ShowInGithub/Properties/Manifest.addin.xml +++ b/ShowInGithub/Properties/Manifest.addin.xml @@ -20,7 +20,7 @@ Fixed incorrect line number in some cases. _label = "Copy Github Link" /> - + diff --git a/ShowInGithub/ShowInGithub.csproj b/ShowInGithub/ShowInGithub.csproj index 312b00f..08eecf7 100644 --- a/ShowInGithub/ShowInGithub.csproj +++ b/ShowInGithub/ShowInGithub.csproj @@ -1,60 +1,17 @@ - - + - Debug - AnyCPU - {86F6BF2A-E449-4B3E-813B-9ACC37E5545F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - {54D3A304-373C-47E1-B83A-97AA0A756627} Library ShowInGithub ShowInGithub - v4.5 + net6.0 + True - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - false - - - full - true - bin\Release - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - + - + - - \ No newline at end of file diff --git a/ShowInGithub/ShowInGithubCommand.cs b/ShowInGithub/ShowInGithubCommand.cs index 0d469ea..6f1fe47 100644 --- a/ShowInGithub/ShowInGithubCommand.cs +++ b/ShowInGithub/ShowInGithubCommand.cs @@ -4,6 +4,8 @@ using MonoDevelop.Ide; using MonoDevelop.Core; using System; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.Editor; namespace ShowInGithub { @@ -18,7 +20,7 @@ public class ShowInGithubCommand: CommandHandler protected override void Update (CommandInfo info) { var doc = IdeApp.Workbench.ActiveDocument; - info.Visible = doc != null && doc.Editor != null && GetGitDir (doc.FileName) != null; + info.Visible = doc != null && doc.GetContent() != null && GetGitDir (doc.FileName) != null; } internal static string GetGitDir (string subdir) @@ -37,7 +39,7 @@ protected override void Run () { var url = GetUrl (); if (url != null) - DesktopService.ShowUrl (url); + IdeServices.DesktopService.ShowUrl (url); } internal static string GetUrl () @@ -116,15 +118,14 @@ internal static string GetUrl () string subdir = doc.FileName.ToRelative (fileRootDir); subdir = subdir.Replace ('\\', '/'); string tline; - if (doc.Editor.SelectionRange.Offset != doc.Editor.SelectionRange.EndOffset) { - var line1 = doc.Editor.OffsetToLineNumber (doc.Editor.SelectionRange.Offset); - var line2 = doc.Editor.OffsetToLineNumber (doc.Editor.SelectionRange.EndOffset); - tline = "L" + line1.ToString (); - if (line1 != line2) - tline += "-L" + line2; - } else { - tline = "L" + doc.Editor.CaretLine; - } + + var textView = doc.GetContent(); + var buffer = textView.TextBuffer; + var line1 = buffer.CurrentSnapshot.GetLineNumberFromPosition(textView.Selection.Start.Position) + 1; + var line2 = buffer.CurrentSnapshot.GetLineNumberFromPosition(textView.Selection.End.Position) + 1; + tline = "L" + line1.ToString(); + if (line1 != line2) + tline += "-L" + line2; return "https://" + host + "/" + repo + "/blob/" + branch + "/" + subdir + "#" + tline; } } @@ -134,7 +135,7 @@ public class CopyGithubLinkCommand: CommandHandler protected override void Update (CommandInfo info) { var doc = IdeApp.Workbench.ActiveDocument; - info.Visible = doc != null && doc.Editor != null && ShowInGithubCommand.GetGitDir (doc.FileName) != null; + info.Visible = doc != null && doc.GetContent() != null && ShowInGithubCommand.GetGitDir (doc.FileName) != null; } protected override void Run () diff --git a/ShowInGithub/packages.config b/ShowInGithub/packages.config deleted file mode 100644 index 384bfdc..0000000 --- a/ShowInGithub/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file