LSP client sends wrong 'workspace/didChangeWatchedFiles' events when Moving / Renaming files
#6,309 opened on Oct 2, 2019
Description
Description
The Theia LSP client sends erroneous 'workspace/didChangeWatchedFiles' events when moving or renaming a file. Moreover, the observed behavior differs depending on the OS hosting the Theia backend.
This is an issue, because a LSP server might rely on this watching behavior to keep track of files inside the workspace. In fact, some language servers (e.g. the Java LSP) throw exceptions because of URIs becoming invalid.
Reproduction Steps
- Open https://gitpod.io#https://github.com/dschafhauser/theia-filesystem-issue or run the example code in a local Theia instance.
- Set Json LSP log level to verbose:
{
"json.trace.server": "verbose"
}
- Open the Json LSP channel on the Output view
- Move a .json file from the root folder to "folder" or vice versa.
- Observe the "workspace/didChangeWatchedFiles" event.
OS and Theia version: Windows host: Windows 10 - 1809 (OS Build 17763.740) Linus host: Linux alpine:3.10.2 Theia Version: 0.10.0
Diagnostics
Scenario 1: Move "Json.json" into the directory "folder" Running on a Windows machine:
Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///d:/workspace/theia-filesystem-issue/Json.json",
"type": 3
},
{
"uri": "file:///d:/workspace/theia-filesystem-issue/folder/Json.json",
"type": 1
}
]
}
=> Correct
Running on a Linux machine / gitpod.io:
Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///workspace/theia-filesystem-issue/Json.json",
"type": 2
}
]
}
=> Wrong
Scenario 2: Rename "Json.json" to "JsonRenamed.json" Running locally on a Windows machine:
Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///d:/workspace/theia-filesystem-issue/Json.json",
"type": 2
},
{
"uri": "file:///d:/workspace/theia-filesystem-issue/JsonRenamed.json",
"type": 1
}
]
}
=> Wrong
Running on a Linux machine / gitpod.io:
Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///workspace/theia-filesystem-issue/Json.json",
"type": 3
},
{
"uri": "file:///workspace/theia-filesystem-issue/JsonRenamed.json",
"type": 1
}
]
}
=> Correct