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

It's difficult to monitor file changes correctly #742

Closed
sumneko opened this issue May 8, 2019 · 6 comments
Closed

It's difficult to monitor file changes correctly #742

sumneko opened this issue May 8, 2019 · 6 comments
Labels
feature-request Request for new features or functionality file events

Comments

@sumneko
Copy link

sumneko commented May 8, 2019

To support global variables, the server needs to monitor all file additions and deletions, so I use the workspace/didChangeWatchedFiles to do that.
However, this protocol is difficult to use correctly, for example:

User's operation

  • Copy and paste a folder containing two files.
  • Modify the name of this folder.
  • Delete this folder.

Expected to receive

  • Create two files.
  • Delete two files and create two files.
  • Delete two files.

Actually received

微信图片_20190508145506

  • Create three files or folders, I need to judge which is file by IO myself.
  • Remove a file or folder and create a file or folder, I need to determine that this is a folder rename so that I can correctly modify the name of the internal two files.
  • Remove a file or folder, I need to remove the internal two files by myself.

I have read some other issues like microsoft/vscode-languageserver-node#141, it seems that this is your design, but this design is very difficult to use, even in addition to the server's own IO, there is no good way to determine whether to add files or folders.

@dbaeumer
Copy link
Member

There is always the possibility that the server does its own file watching without asking the client for events.

@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Oct 31, 2019
@dbaeumer dbaeumer added this to the Backlog milestone Oct 31, 2019
@sumneko
Copy link
Author

sumneko commented Feb 1, 2021

I'm glad to see that you've added a file operations protocol.

The new protocol solves the problem of renaming, but the support for folders is still unfriendly.

At present, if I delete or rename a folder, the protocol only informs the server of the change of the folder (and only provides a URI, which does not indicate whether the URI is a folder or a file).

In fact, most language services don't care about folders. Files are the basic units.

Therefore, I hope that the protocol of file operation can be further strengthened in the future. For example, the option can be added to let the client split the folder event into internal file events (for example, when a folder with 10 files is deleted, the URI of these 10 internal files will be provided in the deletion event).

Finally, thank you for your work!

@sumneko
Copy link
Author

sumneko commented Feb 2, 2021

I found that file events protocol only responds to VSCode operations, not external file operations.

In the real environment, people often create new files because of pulling git. At this time, new files cannot trigger file events protocol.

Is this the design?

If the design is like this, the file events protocol may not be able to meet my needs.

@dbaeumer
Copy link
Member

dbaeumer commented Feb 2, 2021

The design is like this since it allows to return additional edits in case of a rename (see the will*) requests. The file operations are not a replacement of the file events.

Most file system don't provide you with events and of the children even a folder is renamed. If clients might not know the children since the node might have never be presented in an explorer. Scanning the whole file system on the client to simple provide these fine grain events is IMO not the right solution. Since a server knows the files that are loaded into a project it IMO can "easily" compute this itself.

@sumneko
Copy link
Author

sumneko commented Feb 2, 2021

Thank you for your patience and help. I will change to the server to deal with this problem. You are free to close this issue.

@dbaeumer
Copy link
Member

dbaeumer commented Feb 3, 2021

@sumneko thanks for getting back. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality file events
Projects
None yet
Development

No branches or pull requests

2 participants