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 #3523

Closed
rchl opened this issue Aug 31, 2023 · 2 comments
Closed

Code Action doesn't return correct document version #3523

rchl opened this issue Aug 31, 2023 · 2 comments
Labels

Comments

@rchl
Copy link
Collaborator

rchl commented Aug 31, 2023

  1. Add import fs from 'fs'; in a <script> tag
  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.

@so1ve
Copy link
Member

so1ve commented Aug 31, 2023

Shall we report it to volar.js?

@rchl
Copy link
Collaborator Author

rchl commented Aug 31, 2023

Yep. Created volarjs/services#50

@rchl rchl closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2023
@so1ve so1ve added the upstream label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants