nea / MarkdownViewerPlusPlus

A Notepad++ Plugin to view a Markdown file rendered on-the-fly
MIT License
1.17k stars 143 forks source link

`NppTbData.pszModuleName` is not properly assigned when Markdown panel is docked #159

Open rdipardo opened 8 months ago

rdipardo commented 8 months ago

Issue description

A forum user asked a while ago why N++'s built-in Docking Manager never reloads the viewer panel when the application starts. The problem is the plugin's module name is serialized without a file extension. N++ fails to locate the module on disk, so it never gets to call com.insanitydesign.MarkdownViewerPlusPlus.Forms.AbstractRenderer.Init().

Here is what happens when the file extension is written to config.xml as the Init method should be doing:

  1. Click "MarkdownViewer++" on the plugin menu and leave the panel showing
  2. Quit Notepad++
  3. Open %AppData%\Notepad++\config.xml (if you have a system-wide installation), or the config.xml inside your portable installation
  4. Notice that Kbg.NppPluginNET.Main.PluginName is the value of the pluginName attribute, e.g.,
<GUIConfig name="DockingManager" leftWidth="200" rightWidth="664" topHeight="200" bottomHeight="200">
    <PluginDlg pluginName="MarkdownViewer++" id="0" curr="1" prev="-1" isVisible="yes" />
    <!-- . . . -->
</GUIConfig>
  1. Edit the XML to pluginName="MarkdownViewer++.dll", i.e., append the module's file extension; make sure isVisible remains "yes"
  2. Start Notepad++
  3. The panel is automatically opened

Quick fix

--- a/MarkdownViewerPlusPlus/Forms/AbstractRenderer.cs
+++ b/MarkdownViewerPlusPlus/Forms/AbstractRenderer.cs
@@ -115 +115 @@ namespace com.insanitydesign.MarkdownViewerPlusPlus.Forms
-            _nppTbData.pszModuleName = Main.PluginName;
+            _nppTbData.pszModuleName = $"{Main.PluginName}.dll";

Markdown to reproduce

<!-- not a Markdown issue -->

Screenshot

n/a

Environment

n/a