stefankueng / grepWin

A powerful and fast search tool using regular expressions
https://tools.stefankueng.com/grepWin.html
GNU General Public License v3.0
1.72k stars 179 forks source link

Matches in hidden .svn folder appearing in Search Results #495

Closed afij closed 1 month ago

afij commented 1 month ago

In Version 2.1.3.1355 on Windows 10, search matches from the hidden .svn folder are appearing in the results pane.

Hovering the "Exclude dirs" field has a note saying "Note, '.svn' folders are 'hidden' on Windows, so they are usually not scanned". This doesn't seem to be working correctly anymore. I confirmed the folder is still hidden in Windows.

image

stefankueng commented 1 month ago

works fine for me. make sure the hidden flag is really set on the .svn folder. Explorer show the folder in gray even if the flag is not set (right-click on the folder, choose "properties" from the context menu, then check that the "hidden" checkbox is really set).

sicklittlemonkey commented 1 month ago

I'm seeing this too, just recently - maybe since the last Windows update - as I don't recall problems last week.

Edition Windows 11 Pro Version 23H2 Installed on ‎17/‎07/‎2023 OS build 22631.3880 Experience Windows Feature Experience Pack 1000.22700.1020.0

The .svn folder is dimmed: image

It shows as hidden from the command line: image

But I get results like this with the latest GrepWin (2.1.3): image

Manually excluding it doesn't seem to work. Is there any other info I can provide? Thanks for the great tool, and dark mode! : - D

sicklittlemonkey commented 1 month ago

Hmm, I had a quick look. A lot of old school code to understand. ; - )

On an unrelated note, in a debug build I get an abort after searching finishes (when it's trying to populate the grid) even without any changes, so I can't be sure - but I think I found something by diffing from v2.0.15.

When I go through the main loop in my use case, bRecurse is initialized but never re-assigned, so the fileEnumerator.NextFile() iterates through the subdirectories of a ".svn" directory under the root search path, and those results appear the grid. In v2.0.15, it looks like bRecurse is assigned on every iteration. Adding the line below marked with *** seems to help - no ".svn" results appear in the grid (but I still get the abort).

// Lots of code omitted, just leaving the code path of interest ...
DWORD CSearchDlg::SearchThread()
{
    bool bRecurse = bHasLimits && m_bIncludeSubfolders;
    for (const auto& cSearchPath : pathVector)
    {
        while ((fileEnumerator.NextFile(sPath, &bIsDirectory, bRecurse)) && !m_cancelled)
        {
            if (bHasLimits)
            {
                bSearch = (m_bIncludeHidden || ((pFindData->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)) &&
                          (m_bIncludeSystem || ((pFindData->dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) == 0));
                // bRecurse = bRecurse && bSearch; // Fixed if I add this line? ***
                if (bSearch)
                {
                    // bRecurse is only set in here, which I never reach unless I add the line above ***
                    // In v2.0.15 bRecurse is always set on each iteration.
sicklittlemonkey commented 1 month ago

Just to confirm, I downgraded to each release version and tested.

All releases have this problem starting with 2.1.0. I'm now using 2.0.15 without issue.

sicklittlemonkey commented 1 month ago

@stefankueng This works fine in 2.1.4 now, thanks! I hope my notes were helpful.

afij commented 1 month ago

2.1.4 looks good to me after a quick review. Thanks guys!