-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
API: Allow to use the file watcher for aribitrary folders #3025
Comments
Hello. This is not a bug. It is not updating for you because you did not enter your Git credentials. After entering your git credentials, the branch automatically changes. |
Hi @MystK, all operations are local. The credential error in the video is not my point, just a side effect of showing that, after pressing the sync button, the local git status is still not updated. Before that, I pressed the "master" button, this interaction also did not update the status. Until at last, I opened the git panel, new branch finally shows. |
Thanks for the clarification. My apologies. I've tried to reproduce your issue but cannot. I've clones your environment and steps but my branch still switches to the testing branch without having to click the Git panel. |
@MystK, I just find that this happens only when using vscode open a subfolder of a git repository. working on the repository root folder works normal. |
This is due to a lack of file system events within the @bpasero Let's talk about this when you're back. |
It works for me, it just takes a while... |
Actually...it used to track, but it doesn't anymore. That's what I'm seeing on Windows7 anyway with the latest update. |
@joaomoreno thats a tough one, would you want explicit API to listen to a .git folder in the parent chain? I think if git does not find a .git folder to listen on, it should fallback to some polling mechanism instead. |
Well ideally any contribution in Code should be able to tell the filesystem events contribution hey, I wanna listen to all file change events at this given Moving this to feature request and renaming title. |
PR is up at #139881 @joaomoreno just to clarify, the need from the Git extension is to be able to watch some files inside the |
For GitLens (and I'm pretty sure the Git extensions needs) it would need to be recursive, so that we can watch for specific changes within the Here are the watcher patterns GitLens uses today: |
For Prisma's extension we are currently using chokidar and it's recursive |
I just looked at the Git extension and it does not require recursive watching: vscode/extensions/git/src/watch.ts Line 16 in a6177d9
The patterns from GitLens seem fine to me and would work with what I am building in the PR. @Jolg42 you seem to be listening to changes just to a single file but you need to scan any |
@bpasero The most common use case would be indeed watching 1 file that could be in any |
Just FYI for Python extension, we currently use chokidar to watch for python binaries in environment folders outside workspace upto depth 2: https://github.com/microsoft/vscode-python/blob/456ac068e95ba600079ddcdc0cc7551d1659a699/src/client/common/platform/fileSystemWatcher.ts#L57-L81 Common patterns we watch for: link |
Thanks for providing examples, just to clarify what #139881 will allow you to do: createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file('<some folder path>'), '*.js')) Previously we would silently ignore a provided path that is outside the workspace. After my change, paths will be watched, even when they are outside the workspace with 2 different strategies depending on the pattern used:
However, when it comes to how to handle excludes, I am still not sure what to do so that extensions can efficiently use this new behaviour for file watching. To clarify: a user setting "files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.hg/store/**": true
} Besides performance considerations, this setting is also required on Linux to reduce the number of opened file handles the watcher consumes. Unfortunately on Linux, recursive watching requires 1 file handle per folder in the hierarchy and only with these exclude rules are we able to reduce this overhead. To be consistent, this setting needs to apply for extension watched paths as well, otherwise a user would not be in control anymore how file watching works. Given we have 2 different watch strategies, I am thinking:
The downside of this approach is that currently an extension cannot indicate the excludes to use, nor overwrite the default excludes we apply. This probably needs a new overload of the However, even if we were to provide extensions with a way to override excludes, you would still not be able to watch the Open for thoughts and ideas how to proceed. My feeling is that my PR makes git extensions happy because watchers can be installed on git repositories outside the opened workspace. However those extensions that need to watch in a location that is excluded by default (i.e. |
@bpasero will this be landing in the January release and available for extensions or will it have to be proposed first? I'm hoping and assuming the former as I didn't see any proposed Say if you have a repo in: By default, I will put worktrees in: (though this is still TBD) Alternatively, a user can pick a different folder (often I've seen people create worktree folders as peer's to the main): Which again would suffer the same problem since again the real Thanks! |
This is planned to be available in our upcoming January release without the need of proposed API. As I had indicated before, an extension can watch any path that is not within the opened workspace folder hierarchy. For non-recursive watchers, no excludes will apply, but for recursive watchers, the same excludes apply that apply for workspace folder watching. |
…39881) * API: Allow to use the file watcher for aribitrary folders (#3025) * fix tests * update `createFileSystemWatcher` docs * refuse to watch resources that are watched in workspace already * properly check proposed API * make it work via `createFileSystemWacher` (first cut) * more docs * cleanup * enable recursive watching based on pattern * add tests * drop out-of-workspace events when using simple patterns * do not apply excludes when watchig files * log extension watch requests * also log unwatch * improved exclude handling * more docs * drop proposed api needs * remove `suite.only` * cannot watch inside workspace more than once * do not send extension decriptor over * adopt latest changes * add `baseUri` to relative pattern * backwards compat
Since microsoft/vscode#3025 is now fixed, file watching works outside the workspace
Small update for a change I pushed for #146066: with this change you can now create a file system watcher that is watching inside the workspace and the In other words: this enables you to watch a folder or file and be 100% sure that file events get delivered to you even if the user has configured exclude rules (or when our default exclude rules would impact the results). This does not apply for recursive watching though because the exclude rules are there for a reason, to reduce overhead for recursive watching. |
Another update: with #194776 there is now proposed new API for With that change, file events are exclusively routed back to the extension making the request, thus reducing the performance overhead. No component in VS Code core and no other extension will receive these file events. The only requirement for this to work is that you have to provide a set of glob patterns to vscode/src/vscode-dts/vscode.proposed.createFileSystemWatcher.d.ts Lines 10 to 37 in 895a9ff
Finalization is tracked in #169724 |
vscode 0.10.8, windows 10.
like in the video, branch status updated only when clicking git panel.
if auto tracking is not possible, how about update status when clicking the sync button in the status bar?
The text was updated successfully, but these errors were encountered: