Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Search index not refreshed after branch switch? #11891

Open
FezVrasta opened this issue Nov 4, 2015 · 15 comments
Open

Search index not refreshed after branch switch? #11891

FezVrasta opened this issue Nov 4, 2015 · 15 comments

Comments

@FezVrasta
Copy link
Contributor

If I open a git project, then I checkout a different branch, and I try to search for a string (which is present only in the new branch), the search results will be 0 even if the string actually exists.

Seems like that when I switch branch, Brackets doesn't update its index or something like that...

Note that my repository is quite big

@abose
Copy link
Contributor

abose commented Nov 4, 2015

have you used brackets file tree exclude? how many files does the project have.
Usually the indexer watches for file system changes and would update the index with changed contents.
But for large files it might take a while.
Can you see the console messages?

@FezVrasta
Copy link
Contributor Author

I'm using file tree exclude to ignore node and bower (and the build folder).

On the console nothing is printed.

@abose
Copy link
Contributor

abose commented Nov 4, 2015

can you paste the health report after you have executed find in files/instant search?

@FezVrasta
Copy link
Contributor Author

Sure, here the log with extensions loaded:

{
    "uuid": "a5d64652-69f8-40b3-91e1-eebc42efb8cd",
    "snapshotTime": 1446658064792,
    "os": "mac",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Brackets/1.6.0 Chrome/39.0.2171.36 Safari/537.36",
    "osLanguage": "it",
    "bracketsLanguage": "it",
    "bracketsVersion": "1.6.0-0",
    "searchDetails": {
        "searchNew": 21,
        "searchOnReturnKey": 20,
        "searchInstant": 151
    },
    "fileStats": {
        "openedFileExt": {
            "js": 35,
            "hbs": 1,
            "less": 38
        },
        "workingSetFileExt": {
            "less": 5,
            "js": 9
        }
    },
    "ProjectDetails": {
        "prj-634332597": {
            "numFiles": 2334,
            "cacheSize": 43367350
        },
        "prj-1242788334": {
            "numFiles": 1524,
            "cacheSize": 20153451
        }
    },
    "projectLoadTimes": ":294",
    "fileOpenTimes": ":769",
    "ModuleDepsResolved": 1726,
    "AppStartupTime": 4654,
    "prefNodeSearchDisabled": false,
    "prefInstantSearchDisabled": false,
    "installedExtensions": [
        {
            "name": "quick-dark",
            "version": "1.1.6"
        },
        {
            "name": "rain.monokai-dark-soda",
            "version": "1.0.9"
        },
        {
            "name": "stripper-theme",
            "version": "0.1.1"
        },
        {
            "name": "0674272bac.tagrenamer",
            "version": "0.0.2"
        },
        {
            "name": "brackets-darker",
            "version": "3.2.0"
        },
        {
            "name": "brackets-editorconfig",
            "version": "0.0.4"
        },
        {
            "name": "brackets-indentator",
            "version": "1.0.3"
        },
        {
            "name": "busykai.indent-right",
            "version": "0.1.0"
        },
        {
            "name": "emberjs-htmlbars",
            "version": "1.0.2"
        },
        {
            "name": "donebyexperts.quick-show-in-file-tree",
            "version": "0.0.1"
        },
        {
            "name": "globexdesigns.brackets-jscs",
            "version": "0.7.5"
        },
        {
            "name": "htmlbars-syntax",
            "version": "1.2.0"
        },
        {
            "name": "react_jsx",
            "version": "0.0.2"
        },
        {
            "name": "scientech-com-ua.brackets-trailingspaces",
            "version": "0.0.2"
        },
        {
            "name": "winek.brackets-chain-indents",
            "version": "1.0.1"
        },
        {
            "name": "brackets-indent-guides",
            "version": "1.3.5"
        },
        {
            "name": "enturn.quick-search",
            "version": "1.1.4"
        },
        {
            "name": "camden.csslint",
            "version": "2.0.21"
        },
        {
            "name": "gruehle.markdown-preview",
            "version": "1.0.11"
        },
        {
            "name": "camden.jshint",
            "version": "2.2.18"
        },
        {
            "name": "pflynn.svg.preview",
            "version": "1.3.0"
        },
        {
            "name": "brackets-terminal",
            "version": "0.3.0"
        },
        {
            "name": "pedelman.brackets-surround",
            "version": "1.0.4"
        },
        {
            "name": "aivanov.command-line-shortcuts",
            "version": "0.2.4"
        },
        {
            "name": "brackets-unused-files",
            "version": "1.0.4"
        },
        {
            "name": "ws-sanitizer",
            "version": "1.2.1"
        },
        {
            "name": "dnbard.extensions-rating",
            "version": "0.7.3"
        },
        {
            "name": "brackets-lorem-ipsum",
            "version": "1.0.3"
        },
        {
            "name": "fdecampredon.brackets-epic-linter",
            "version": "0.3.0"
        },
        {
            "name": "jonwolfe.file-tree-exclude",
            "version": "0.6.3"
        },
        {
            "name": "jeffbooher.new-project",
            "version": "0.4.98"
        },
        {
            "name": "hirse.print-margin",
            "version": "0.3.2"
        },
        {
            "name": "brackets-code-folding",
            "version": "0.3.5"
        },
        {
            "name": "zaggino.brackets-git",
            "version": "0.14.32"
        },
        {
            "name": "mikaeljorhult.brackets-todo",
            "version": "0.8.1"
        },
        {
            "name": "theseus",
            "version": "0.4.19"
        },
        {
            "name": "adobe.brackets.extract",
            "version": "0.7.2-1724-release"
        }
    ],
    "bracketsTheme": "stripper-theme"
}

I've also done the test restarting brackets without extensions to make sure it's not an extension fault.

{
    "uuid": "a5d64652-69f8-40b3-91e1-eebc42efb8cd",
    "snapshotTime": 1446657938369,
    "os": "mac",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Brackets/1.6.0 Chrome/39.0.2171.36 Safari/537.36",
    "osLanguage": "it",
    "bracketsLanguage": "it",
    "bracketsVersion": "1.6.0-0",
    "searchDetails": {
        "searchNew": 19,
        "searchOnReturnKey": 19,
        "searchInstant": 144
    },
    "fileStats": {
        "openedFileExt": {
            "js": 33,
            "hbs": 1,
            "less": 38
        },
        "workingSetFileExt": {
            "less": 5,
            "js": 9
        }
    },
    "ProjectDetails": {
        "prj-634332597": {
            "numFiles": 2334,
            "cacheSize": 43367350
        },
        "prj-1242788334": {
            "numFiles": 17066,
            "cacheSize": 167953075
        }
    },
    "projectLoadTimes": ":105",
    "fileOpenTimes": ":405",
    "ModuleDepsResolved": 14211,
    "AppStartupTime": 14965,
    "prefNodeSearchDisabled": false,
    "prefInstantSearchDisabled": false,
    "installedExtensions": []
}

@abose
Copy link
Contributor

abose commented Nov 5, 2015

I tested this out and the index is updated on branch switch and the search results are updated too as soon as the branch switch occurs. Can you restart brackets[exit and relaunch- not just reload] and see if that helps?
It could be that file system change notifiers got broken.

@FezVrasta
Copy link
Contributor Author

I've already restarted it several times.

@abose
Copy link
Contributor

abose commented Nov 5, 2015

Does this happen in smaller projects?

@FezVrasta
Copy link
Contributor Author

I'll try today

@peterflynn
Copy link
Member

@abose I've been seeing this sporadically ever since "instant search" landed. I emailed @nethip about it a long time ago (when the feature first landed) but since it doesn't repro all the time it's a little hard to pin down.

I inspected the code FindInFiles. _fileSystemChangeHandler() code and didn't see anything immediately obvious in terms of update-notification cases being missed. But I'm certain it's not the filesystem change watchers that are the problem -- the file in the editor is correct, and only the search results are wrong.

For example if you click a search result, you'll actually see it highlight the wrong text range in the file. Or if you know a result is missing from a certain file, you can open it and see the missed result right there. So the filesystem code spotted the change on disk and updated the cache on the Brackets/CEF side -- it's just the cache on the Node side that missed the change.

@peterflynn
Copy link
Member

One thing to look at possibly is what the Node side does when it's unable to immediately reread a file that has changed or been created. Git checkouts might create enough notification churn that a file is missing or locked by the time Node tries to read it, even if the file might get recreated later in the checkout.

Is there any possibility of cases where the Node side gives up on a whole queue of files to read just because one failed? Or race conditions where JS sees several changes to a file (including a delete + re-add) and Node ignores the file because it can't read it but the re-add isn't added to the queue because Node thinks it's still already in the queue to stuff to read?

@peterflynn
Copy link
Member

In any event, marking as a high priority since it erodes trust in the search feature. It's made me tempted to comment instant search to disable it, or use other tools for Find in Files a few times -- and I'm more forgiving of Brackets than the average user :-)

Lmk if you disagree with that priority call.

@peterflynn
Copy link
Member

Oh, and fwiw I do not use the file system exclude plugin.

@abose
Copy link
Contributor

abose commented Nov 19, 2015

I just went through the code again, and on file system change events, The list of changed file names is sent to node; which will remove it from node cache. The file read will not happen at the time. It happens only when the next time a search requests for file contents. So the locked file case should not apply here. On any file system changed event, the only thing node does is to remove the content for the filename from cache.

When this happens, close find in files panel.Redo the search for the same query. Does it show the new results after that?

@paulfalgout
Copy link

I'm also seeing this. After switching branches I can't find new code that is on that branch.. even if I'm looking at it. however I also can't find code from the branch I just left, so it isn't searching the old branch either

@abose
Copy link
Contributor

abose commented Nov 25, 2015

Do you see any console logs?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants
@peterflynn @paulfalgout @abose @FezVrasta and others