eclipse-theia/theia

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

开放

#6,309 创建于 2019年10月2日

 (2 条评论) (0 个反应) (0 位负责人)TypeScript (2,478 个派生)batch import
bugfilesystemhelp wantedvscode

仓库指标

星标
 (18,676 个星标)
PR 合并指标
 (平均合并 15天 4小时) (30 天内合并 75 个 PR)

描述

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"
}
  1. Open the Json LSP channel on the Output view
  2. Move a .json file from the root folder to "folder" or vice versa.
  3. 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

贡献者指南