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

Code Action doesn't return correct document version #50

Open
rchl opened this issue Aug 31, 2023 · 0 comments
Open

Code Action doesn't return correct document version #50

rchl opened this issue Aug 31, 2023 · 0 comments

Comments

@rchl
Copy link

rchl commented Aug 31, 2023

  1. Add import fs from 'fs'; in a <script> tag in Vue file
  2. Trigger code actions on that line and select Delete all unused imports

Volar doesn't return matching document version in the codeAction/resolve response.

[Trace - 11:01:42] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///usr/local/workspace/file.vue",
        "version": 2
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 86,
                    "character": 0
                },
                "end": {
                    "line": 86,
                    "character": 0
                }
            },
            "rangeLength": 0,
            "text": "import fs from 'fs';"
        }
    ]
}

[Trace - 11:01:48] Received response 'codeAction/resolve - (25)' in 7ms.
Result: {
    "title": "Delete all unused imports",
    "data": {
        "uri": "file:///usr/local/workspace/file.vue.ts",
        "type": "fixAll",
        "fileName": "/usr/local/workspace/file.vue.ts",
        "fixIds": [
            "unusedIdentifier_deleteImports"
        ]
    },
    "kind": "",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 6,
                    "character": 0
                },
                "end": {
                    "line": 6,
                    "character": 20
                }
            },
            "message": "'fs' is declared but its value is never read.",
            "data": {
                "uri": "file:///usr/local/workspace/file.vue",
                "version": 4,
                "type": "service",
                "serviceOrRuleId": "typescript",
                "isFormat": false,
                "original": {},
                "ruleFixIndex": 0,
                "documentUri": "file:///usr/local/workspace/file.vue.ts"
            },
            "code": 6133,
            "severity": 4,
            "tags": [
                1
            ],
            "source": "ts"
        }
    ],
    "edit": {
        "documentChanges": [
            {
                "textDocument": {
                    "uri": "file:///usr/local/workspace/file.vue",
                    "version": 4
                },
                "edits": [
                    {
                        "newText": "",
                        "range": {
                            "start": {
                                "line": 86,
                                "character": 0
                            },
                            "end": {
                                "line": 87,
                                "character": 0
                            }
                        }
                    }
                ]
            }
        ]
    }
}

As can be seen here, Volar specified version 4 in the code action while the document is at version 2 right now.

It appears that VSCode doesn't really care about version and still applies the edit but in case of Sublime Text the edit is ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant