Skip to content

Commit

Permalink
Implement NPPN_GLOBALMODIFIED callback
Browse files Browse the repository at this point in the history
not sure if it was necessary, but now it's done
  • Loading branch information
molsonkiko committed Feb 24, 2024
1 parent 4dbb720 commit d7edad1
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 45 deletions.
2 changes: 1 addition & 1 deletion JsonToolsNppPlugin/Forms/TreeViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public partial class TreeViewer : Form
public bool documentTypeIndexChangeWasAutomatic;

/// <summary>
/// If the user performs an undo or redo action,
/// If the user modifies the buffer belonging to this treeview,
/// this will be set to true so that the next time the user performs a RemesPath query,
/// the treeview is reset beforehand.
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion JsonToolsNppPlugin/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,20 @@ public static void OnNotification(ScNotification notification)
// if the user did nothing for a while (default 1 second) after editing,
// re-parse the file and also perform validation if that's enabled.
case (uint)SciMsg.SCN_MODIFIED:
// only turn on the flag if the user performed the modification
lastEditedTime = System.DateTime.UtcNow;
if (openTreeViewer != null)
openTreeViewer.shouldRefresh = true;
break;
// a find/replace action was performed.
// Tag the treeview of the modified file as needing to refresh, and indicate that the document was edited.
case (uint)NppMsg.NPPN_GLOBALMODIFIED:
IntPtr bufferModifiedId = notification.Header.hwndFrom;
string bufferModified = Npp.notepad.GetFilePath(bufferModifiedId);
if (bufferModified == activeFname)
lastEditedTime = System.DateTime.UtcNow;
if (TryGetInfoForFile(bufferModified, out info) && !(info.tv is null) && !info.tv.IsDisposed)
info.tv.shouldRefresh = true;
break;
//if (code > int.MaxValue) // windows messages
//{
// int wm = -(int)code;
Expand Down
11 changes: 11 additions & 0 deletions JsonToolsNppPlugin/PluginInfrastructure/Msgs_h.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,17 @@ public enum NppMsg : uint
/// </summary>
NPPN_FILEDELETED = NPPN_FIRST + 26,

/// <summary>
/// To notify plugins that the current document is just modified by Replace All action.<br></br>
/// For solving the performance issue (from v8.6.4), Notepad++ doesn't trigger SCN_MODIFIED during Replace All action anymore.<br></br>
/// As a result, the plugins which monitor SCN_MODIFIED should also monitor NPPN_GLOBALMODIFIED.<br></br>
/// <strong>This notification is implemented in Notepad++ v8.6.5.</strong><br></br>
/// scnNotification->nmhdr.code = NPPN_GLOBALMODIFIED;<br></br>
/// scnNotification->nmhdr.hwndFrom = BufferID;<br></br>
/// scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero
/// </summary>
NPPN_GLOBALMODIFIED = NPPN_FIRST + 30,

/* --Autogenerated -- end of section automatically generated from notepad-plus-plus\PowerEditor\src\MISC\PluginsManager\Notepad_plus_msgs.h * */
}

Expand Down
4 changes: 2 additions & 2 deletions JsonToolsNppPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("7.0.0.3")]
[assembly: AssemblyFileVersion("7.0.0.3")]
[assembly: AssemblyVersion("7.0.0.4")]
[assembly: AssemblyFileVersion("7.0.0.4")]
Loading

0 comments on commit d7edad1

Please sign in to comment.