Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh search results on unhide, show open files on first load. #54

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions NppNavigateTo/Forms/FrmNavigateTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public FrmNavigateTo(IScintillaGateway editor, INotepadPPGateway notepad)
ReloadFileList();
this.notepad.ReloadMenuItems();
FormStyle.ApplyStyle(this, true, notepad.IsDarkModeEnabled());
FilterDataGrid("");
}

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

if (textLength == 0)
if (emptyText)
ReloadFileList();
if (textLength > minLength)
if (textLength > minLength || emptyText)
{
FilterDataGrid(searchComboBox.Text);
}
Expand Down Expand Up @@ -886,6 +888,12 @@ private void FrmNavigateAll_KeyPress(object sender, KeyPressEventArgs e)
}
}

public void GrabFocus()
{
searchComboBox.Select();
FilterDataGrid(searchComboBox.Text);
}

private void dataGridFileList_KeyPress(object sender, KeyPressEventArgs e)
{
searchComboBox.Focus();
Expand Down
2 changes: 1 addition & 1 deletion NppNavigateTo/Glob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public Regex Glob2Regex(string inp)
ii++;
}
endOfLoop:
if (uses_metacharacters) // anything without "*" or "?" or "[]" or
if (uses_metacharacters) // anything without any chars in "*?[]{}" will just be treated as a normal string
sb.Append('$'); // globs are anchored at the end; that is "*foo" does not match "foo/bar.txt" but "*foo.tx?" does
string pat = sb.ToString();
try
Expand Down
2 changes: 2 additions & 0 deletions NppNavigateTo/NppNavigateTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ static void NavigateToDlg()
frmNavigateTo.Handle);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 1);
frmNavigateTo.GrabFocus();
}
else
{
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0,
frmNavigateTo.Handle);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 0);
editor.GrabFocus();
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions NppNavigateTo/Tests/GlobTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ public static void Test()
("foo.jsonl", false),
("c:\\bar.txto", false),
}),
("*.p* !< __ | \\j", new[]
{
("bep.po", true),
("joo.po", true),
("boo\\joo.po", false),
("bbq.go", false),
("__bzz.po", false),
("boo\\j__.po", false),
("boo__\\eorpwn\\reiren.po", false),
("Z:\\jnq\\eorpwn\\reiren.po", false),
}),
};
var glob = new Glob();
foreach ((string query, var examples) in testcases)
Expand Down
2 changes: 1 addition & 1 deletion test_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Test results for NavigateTo v2.6
Testing Glob syntax
=========================

Ran 94 tests and failed 0
Ran 102 tests and failed 0