Skip to content

Commit 87ea359

Browse files
committed
refresh form on unhide, show open files @ 1st load
Problems that this commit should solve: 1. Hiding or showing the form changing input focus in an unclear way (issue #53) 2. Nothing showing when the form is first loaded (issue #36) 3. When the form is reloaded, it showed out-of-date search results (e.g., it would show files in the top directory of a file that is no longer active) There was no associated issue for this, but it bugged me.
1 parent 9293f7b commit 87ea359

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

NppNavigateTo/Forms/FrmNavigateTo.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public FrmNavigateTo(IScintillaGateway editor, INotepadPPGateway notepad)
103103
ReloadFileList();
104104
this.notepad.ReloadMenuItems();
105105
FormStyle.ApplyStyle(this, true, notepad.IsDarkModeEnabled());
106+
FilterDataGrid("");
106107
}
107108

108109
/// <summary>
@@ -617,11 +618,12 @@ private bool NavigateGridDown(bool isShiftPressed)
617618
private void SearchComboBoxTextChanged(object sender, EventArgs e)
618619
{
619620
int textLength = searchComboBox.Text.Length;
621+
bool emptyText = string.IsNullOrWhiteSpace(searchComboBox.Text);
620622
int minLength = FrmSettings.Settings.GetIntSetting(Settings.minTypeCharLimit);
621623

622-
if (textLength == 0)
624+
if (emptyText)
623625
ReloadFileList();
624-
if (textLength > minLength)
626+
if (textLength > minLength || emptyText)
625627
{
626628
FilterDataGrid(searchComboBox.Text);
627629
}
@@ -886,6 +888,12 @@ private void FrmNavigateAll_KeyPress(object sender, KeyPressEventArgs e)
886888
}
887889
}
888890

891+
public void GrabFocus()
892+
{
893+
searchComboBox.Select();
894+
FilterDataGrid(searchComboBox.Text);
895+
}
896+
889897
private void dataGridFileList_KeyPress(object sender, KeyPressEventArgs e)
890898
{
891899
searchComboBox.Focus();

NppNavigateTo/Glob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public Regex Glob2Regex(string inp)
197197
ii++;
198198
}
199199
endOfLoop:
200-
if (uses_metacharacters) // anything without "*" or "?" or "[]" or
200+
if (uses_metacharacters) // anything without any chars in "*?[]{}" will just be treated as a normal string
201201
sb.Append('$'); // globs are anchored at the end; that is "*foo" does not match "foo/bar.txt" but "*foo.tx?" does
202202
string pat = sb.ToString();
203203
try

NppNavigateTo/NppNavigateTo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,15 @@ static void NavigateToDlg()
204204
frmNavigateTo.Handle);
205205
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
206206
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 1);
207+
frmNavigateTo.GrabFocus();
207208
}
208209
else
209210
{
210211
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0,
211212
frmNavigateTo.Handle);
212213
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
213214
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 0);
215+
editor.GrabFocus();
214216
}
215217
}
216218
}

NppNavigateTo/Tests/GlobTester.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ public static void Test()
167167
("foo.jsonl", false),
168168
("c:\\bar.txto", false),
169169
}),
170+
("*.p* !< __ | \\j", new[]
171+
{
172+
("bep.po", true),
173+
("joo.po", true),
174+
("boo\\joo.po", false),
175+
("bbq.go", false),
176+
("__bzz.po", false),
177+
("boo\\j__.po", false),
178+
("boo__\\eorpwn\\reiren.po", false),
179+
("Z:\\jnq\\eorpwn\\reiren.po", false),
180+
}),
170181
};
171182
var glob = new Glob();
172183
foreach ((string query, var examples) in testcases)

0 commit comments

Comments
 (0)