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

API: Provide an onMoved event for when the user moves a file/folder in the explorer #24846

Closed
stringham opened this issue Apr 16, 2017 · 12 comments
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality

Comments

@stringham
Copy link
Contributor

I created an extension which updates relative imports when you move a typescript file or a folder. Unfortunately, it's kind of clunky because it only works when the user uses the explorer context menu or the command pallet to move the items.

It would be great if I could hook into an event which occurs when the user moves a file or folder in the explorer. The FileSystemWatcher API currently has hooks for creation, deletion, and modification.

It would be possible to detect a file move with the onCreate and onDelete methods, but those events happen even when the creation/deletion originate from outside of vscode.

@jrieken
Copy link
Member

jrieken commented Apr 18, 2017

needs underlying infrastructure from our fs-event service

@bpasero
Copy link
Member

bpasero commented Apr 18, 2017

I am not aware of a cross platform file watcher that detects moves (instead of reporting ADD followed by a DELETE event).

@bpasero bpasero added api feature-request Request for new features or functionality labels Apr 18, 2017
@bpasero bpasero removed their assignment Apr 18, 2017
@stringham
Copy link
Contributor Author

I'm not interested in getting the information from the file watcher. I'd just like to know when the user drags and drops a file or folder in the vs code explorer or when a user renames a file or folder in the vs code explorer.

I want to respond to the user's action rather than to the file system changing.

@stringham
Copy link
Contributor Author

@jrieken @bpasero does that make sense?

I don't want another file system API, I want vscode to emit an event when the user uses the explorer to move/rename.

@asvetliakov
Copy link

+1 for this. I implemented similar move extension by checking content hashes of files. Something like onDidMove() would be helpful.

Also noticed what onDidDelete() events don't come from FS watcher if you rename/move folder, only onDidCreate(), but for single file both onDidCreate/onDidDelete evens are being sent

@jrieken
Copy link
Member

jrieken commented May 15, 2017

I don't want another file system API, I want vscode to emit an event when the user uses the explorer to move/rename.

Not sure yet, other extension author might be confused by this. Ideally, we know this for good using the OS primitives (file events). Think of some one moving a file with the terminal (inside the tool) or think of cut and pasting a file.

@dymo
Copy link

dymo commented May 18, 2017

A solution could be to create a WorkspaceWatcher that has add, change, rename, move and remove events. Then it would be clear to the extension developer that it is not file system events, so rename and move done outside VS Code, would result in remove and add events.

You could also add workspaceRename and workspaceMove events to the FileSystemWatcher, but please see #26852 first.

@jrieken
Copy link
Member

jrieken commented May 18, 2017

Then it would be clear to the extension developer that it is not file system events, so rename and move done outside VS Code,

If you are just interested in us having done this, basically via explorer gestures, you want this: #1431 That issue is about letting people folks when a certain command ran or will run. That would be the better representation for that is because it doesn't have much to do with file watching anymore

@mishkinf
Copy link

mishkinf commented Apr 11, 2018

+1 I also really want an onRename(oldResource, newResource)

It looks like those vscode editor actions drill down into: https://github.com/Microsoft/vscode/blob/f686a20863de110239dcdc47a164fa576b2938ea/src/vs/workbench/services/files/electron-browser/remoteFileService.ts#L410

https://github.com/Microsoft/vscode/blob/f686a20863de110239dcdc47a164fa576b2938ea/src/vs/workbench/services/files/electron-browser/remoteFileService.ts#L401

@bpasero is there any clean way these events can be propagated up into some sort of clean API for extensions and such?

@bpasero
Copy link
Member

bpasero commented Aug 11, 2019

@stringham isn't this the same ask as #43768

I think we solved this already because in TS when I move a file I am being asked to update imports.

@jrieken
Copy link
Member

jrieken commented Aug 12, 2019

/duplicate of #43768

@vscodebot vscodebot bot added the *duplicate Issue identified as a duplicate of another issue(s) label Aug 12, 2019
@vscodebot
Copy link

vscodebot bot commented Aug 12, 2019

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Aug 12, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants