I could've sworn I made an issue for this; I was very excited about it around this time last year. Can't find it, so here I go again.
Language servers have the ability to be asked questions from an editor such as “I'm about to move foo/bar.js to baz/bar.js; would you want to react to that in any way?” In that scenario, the language server is likely to say, “yes! let me see if anything imports that file; if so, those imports will need updating so that they point to bar.js’s new destination on disk.”
This is something that can Just Work if we do it right. Any user-initiated actions that come from the tree-view package should invoke the respective callbacks:
- A user dragging an item from one destination to another should trigger an
onWillMove callback and then an onDidMove callback (before and after the move).
- A user creating a new file from the tree view should trigger
onWillCreate and onDidCreate.
- A user deleting a file from the tree view should trigger
onWillDelete and onDidDelete.
This will require some care in how the tree-view service is extended. Those onWill* callbacks have the theoretical ability to delay the file operation while the requested work is performed (in our example from above, some TextEdits will need to be applied to arbitrary workspace files) but we shouldn't make tree-view wait indefinitely! I designed the service API such that the consumer can request a delay on the operation while the consumer does some async work (like talk to a language server) but tree-view should still have some sort of reasonable timeout on the work (1-2 seconds) so that the user isn't just stuck waiting there and not knowing why.
There's another thing we should add to the tree-view service while we're at it: the ability to programmatically select and reveal a certain file. This would come in handy for the terminal package; we should be able to do something if a certain directory name is printed in the terminal (or hyperlinked to) and the user clicks on it.
I could've sworn I made an issue for this; I was very excited about it around this time last year. Can't find it, so here I go again.
Language servers have the ability to be asked questions from an editor such as “I'm about to move
foo/bar.jstobaz/bar.js; would you want to react to that in any way?” In that scenario, the language server is likely to say, “yes! let me see if anything imports that file; if so, thoseimports will need updating so that they point tobar.js’s new destination on disk.”This is something that can Just Work if we do it right. Any user-initiated actions that come from the
tree-viewpackage should invoke the respective callbacks:onWillMovecallback and then anonDidMovecallback (before and after the move).onWillCreateandonDidCreate.onWillDeleteandonDidDelete.This will require some care in how the
tree-viewservice is extended. ThoseonWill*callbacks have the theoretical ability to delay the file operation while the requested work is performed (in our example from above, someTextEdits will need to be applied to arbitrary workspace files) but we shouldn't maketree-viewwait indefinitely! I designed the service API such that the consumer can request a delay on the operation while the consumer does some async work (like talk to a language server) buttree-viewshould still have some sort of reasonable timeout on the work (1-2 seconds) so that the user isn't just stuck waiting there and not knowing why.There's another thing we should add to the
tree-viewservice while we're at it: the ability to programmatically select and reveal a certain file. This would come in handy for theterminalpackage; we should be able to do something if a certain directory name is printed in the terminal (or hyperlinked to) and the user clicks on it.