diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e50c8..5718f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). 1. Fixed issue where clicking buttons on floating docking dialogs could sometimes cause Notepad++ to hang forever (see [CsvLint issue 83](https://github.com/BdR76/CSVLint/issues/83) for a detailed explanation). 2. Fix `SCNotification` byte alignment issue in 64-bit Notepad++ by making `annotationLinesAdded` field an `IntPtr`, which has been the correct type for that field since [between Notepad++ 7.6.6 and 7.7](https://github.com/notepad-plus-plus/notepad-plus-plus/blob/37c4b894cc247d1ee6976bc1a1b66cfed4b7774e/scintilla/include/Scintilla.h#L1227). Note that *this is a potentially breaking change for 64-bit Notepad++ 7.6.6 or older*, but there's a ton of other bit rot for such old Notepad++ anyway. +3. Fix error due to assuming that "." (the current directory according to the filesystem) will always point to the path to the Notepad++ executable; this is *almost always true*, but can be broken due to at least one known weird interaction (the one molsonkiko is familiar with concerns the `New script` functionality of the PythonScript plugin). ## [0.0.3] - 2024-02-26 diff --git a/NppCSharpPluginPack/Main.cs b/NppCSharpPluginPack/Main.cs index db0573f..67e4129 100644 --- a/NppCSharpPluginPack/Main.cs +++ b/NppCSharpPluginPack/Main.cs @@ -103,11 +103,7 @@ static internal void CommandMenuInit() private static Assembly LoadDependency(object sender, ResolveEventArgs args) { - // Path.GetFullPath(".") will return the path to the Notepad++ executable - // I have *very rarely* seen it instead return another path, but in general this should work properly. - // Unfortunately Npp.notepad.GetNppPath() cannot be used here for reasons discussed in this comment by rdipardo: - // https://github.com/molsonkiko/NppCSharpPluginPack/issues/5#issuecomment-1982167513 - string assemblyFile = Path.Combine(Path.GetFullPath("."), "plugins", PluginName, new AssemblyName(args.Name).Name) + ".dll"; + string assemblyFile = Path.Combine(Npp.pluginDllDirectory, new AssemblyName(args.Name).Name) + ".dll"; if (File.Exists(assemblyFile)) return Assembly.LoadFrom(assemblyFile); return null; diff --git a/NppCSharpPluginPack/Properties/AssemblyInfo.cs b/NppCSharpPluginPack/Properties/AssemblyInfo.cs index f934159..fcad6dc 100644 --- a/NppCSharpPluginPack/Properties/AssemblyInfo.cs +++ b/NppCSharpPluginPack/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.0.3.3")] -[assembly: AssemblyFileVersion("0.0.3.3")] +[assembly: AssemblyVersion("0.0.3.4")] +[assembly: AssemblyFileVersion("0.0.3.4")] diff --git a/NppCSharpPluginPack/Tests/TestRunner.cs b/NppCSharpPluginPack/Tests/TestRunner.cs index 99375b4..efc49b9 100644 --- a/NppCSharpPluginPack/Tests/TestRunner.cs +++ b/NppCSharpPluginPack/Tests/TestRunner.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using NppDemo.Utils; using Kbg.NppPluginNET; +using System.IO; namespace NppDemo.Tests { @@ -21,7 +22,7 @@ public static void RunAll() string header = $"Test results for {Main.PluginName} v{Npp.AssemblyVersionString()} on Notepad++ {Npp.nppVersionStr}\r\nNOTE: Ctrl-F (regular expressions *on*) for \"Failed [1-9]\\d*\" to find all failed tests"; Npp.AddLine(header); - string big_random_fname = $"plugins\\{Main.PluginName}\\testfiles\\big_silly_example.tsv"; + string big_random_fname = Path.Combine(Npp.pluginDllDirectory, "testfiles", "big_silly_example.tsv"); var tests = new (Func tester, string name, bool onlyIfNpp8Plus)[] { (SliceTester.Test, "slice extension", false), diff --git a/NppCSharpPluginPack/Utils/Npp.cs b/NppCSharpPluginPack/Utils/Npp.cs index 90c998d..f5adfb4 100644 --- a/NppCSharpPluginPack/Utils/Npp.cs +++ b/NppCSharpPluginPack/Utils/Npp.cs @@ -38,6 +38,14 @@ public class Npp public static readonly bool nppVersionAtLeast8 = nppVersion[0] >= 8; + /// + /// the directory containing of the plugin DLL (i.e., the DLL that this code compiles into)

+ /// usually Path.Combine(notepad.GetNppPath(), "plugins", Main.PluginName) would work just as well,

+ /// but under some weird circumstances (see this GitHub issue comment: https://github.com/molsonkiko/NppCSharpPluginPack/issues/5#issuecomment-1982167513)

+ /// it can fail. + ///
+ public static readonly string pluginDllDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + /// /// append text to current doc, then append newline and move cursor /// diff --git a/most recent errors.txt b/most recent errors.txt index d1e4495..f0f297c 100644 --- a/most recent errors.txt +++ b/most recent errors.txt @@ -1,4 +1,4 @@ -Test results for CSharpPluginPack v0.0.3.3 on Notepad++ 8.6.4 64bit +Test results for CSharpPluginPack v0.0.3.4 on Notepad++ 8.6.4 64bit NOTE: Ctrl-F (regular expressions *on*) for "Failed [1-9]\d*" to find all failed tests No tests failed ========================= @@ -22,7 +22,7 @@ Performance tests for My benchmarks (test1) ========================= To run query "foo" on file of size 7913 into took 0 +/- 0 ms over 32 trials -Query times (ms): 0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +Query times (ms): 0.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Preview of result: Preview of result ========================= Performance tests for My benchmarks (test2)