Skip to content

Commit 67606f3

Browse files
committed
simplify shutdown check; reload files iff visible
1 parent eeb7b2b commit 67606f3

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

NppNavigateTo/Forms/FrmNavigateTo.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ void SearchInCurrentDirectory(string[] words)
108108

109109
public void FilterDataGrid(string filter)
110110
{
111-
// a bunch of NPPN_BUFFERACTIVATED events fire when Notepad++ is shutting down
112-
// which will lead to this being called repeatedly
113-
if (isShuttingDown)
114-
return;
115111
if (!string.IsNullOrEmpty(searchComboBox.Text)) filter = searchComboBox.Text;
116112

117113
if (!string.IsNullOrWhiteSpace(filter))
@@ -283,8 +279,6 @@ private void FilterMenuCommands(string[] filterWords)
283279

284280
public void ReloadFileList()
285281
{
286-
if (isShuttingDown)
287-
return;
288282
if (FileList == null) FileList = new List<FileModel>();
289283
FileList.Clear();
290284
int firstViewCount =

NppNavigateTo/NppNavigateTo.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ public static void OnNotification(ScNotification notification)
5050
switch (notification.Header.Code)
5151
{
5252
case (uint)NppMsg.NPPN_BEFORESHUTDOWN:
53-
var frmNavigateTo = NavigateTo.Plugin.Namespace.Main.frmNavigateTo;
54-
if (frmNavigateTo == null)
55-
return;
56-
frmNavigateTo.isShuttingDown = true;
57-
break;
53+
NavigateTo.Plugin.Namespace.Main.isShuttingDown = true;
54+
break;
5855
case (uint)NppMsg.NPPN_FILEOPENED:
5956
case (uint)NppMsg.NPPN_FILECLOSED:
6057
case (uint)NppMsg.NPPN_FILERENAMED:
@@ -66,10 +63,14 @@ public static void OnNotification(ScNotification notification)
6663
// having a static unchanging editor object no longer works.
6764
// this makes the editor track the current instance.
6865
NavigateTo.Plugin.Namespace.Main.editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
69-
frmNavigateTo = NavigateTo.Plugin.Namespace.Main.frmNavigateTo;
70-
if (frmNavigateTo == null)
66+
var frmNavigateTo = NavigateTo.Plugin.Namespace.Main.frmNavigateTo;
67+
if (frmNavigateTo == null || NavigateTo.Plugin.Namespace.Main.isShuttingDown)
68+
// a bunch of NPPN_BUFFERACTIVATED events fire when Notepad++ is shutting down
69+
// which will lead to this being called repeatedly
7170
return;
7271
frmNavigateTo.shouldReloadFilesInDirectory = notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED;
72+
if (!frmNavigateTo.Visible)
73+
return;
7374
frmNavigateTo.ReloadFileList();
7475
frmNavigateTo.FilterDataGrid("");
7576
break;
@@ -105,6 +106,7 @@ class Main
105106
static INotepadPPGateway notepad = new NotepadPPGateway();
106107
public static FrmNavigateTo frmNavigateTo = null;
107108
public static FrmSettings frmSettings = new FrmSettings(editor, notepad);
109+
public static bool isShuttingDown = false;
108110

109111
#endregion
110112

0 commit comments

Comments
 (0)