eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.96k stars 2.5k forks source link

LSP client sends wrong 'workspace/didChangeWatchedFiles' events when Moving / Renaming files #6309

Open dschafhauser opened 5 years ago

dschafhauser commented 5 years ago

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

  1. Open https://gitpod.io#https://github.com/dschafhauser/theia-filesystem-issue or run the example code in a local Theia instance.
  2. Set Json LSP log level to verbose:
    {
    "json.trace.server": "verbose"
    }
  3. Open the Json LSP channel on the Output view
  4. Move a .json file from the root folder to "folder" or vice versa.
  5. 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

akosyakov commented 5 years ago

@dschafhauser thank you for the issue, could you try please whether it is still reproducible with the master. Yesterday a fix was merged related to handling fo fs rename events.

tsmaeder commented 3 years ago

We no longer use LSP, but if we generate the wrong events, we might have the same issue with the vscode API.