Microsoft/TypeScript

Rename JSDoc param tag quick fix should generate more minimal edit

Open

#47.922 geöffnet am 16. Feb. 2022

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Experience EnhancementHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Bug Report

🔎 Search Terms

  • quick fix
  • code action
  • jsdoc

🕗 Version & Regression Information

4.7.0-dev.20220216

This is new behavior and not a regression

💻 Repo

  1. For the TypeScript:
/**
 * @param c
 * @param d
 */
function add(a, b) { }
  1. Trigger the rename @param tag quick fix on c inside the JSDoc.

🙁 Actual behavior

In VS Code, the cursor shifts to the start of the doc block. This is because the returned code action regenerates the entire start of the JSDoc block

 {
        "fixName": "renameUnmatchedParameter",
        "description": "Rename '@param' tag name 'c' to 'a'",
        "changes": [
            {
                "fileName": "/Users/matb/projects/san/index.ts",
                "textChanges": [
                    {
                        "start": {
                            "line": 1,
                            "offset": 1
                        },
                        "end": {
                            "line": 5,
                            "offset": 1
                        },
                        "newText": ""
                    },
                    {
                        "start": {
                            "line": 5,
                            "offset": 1
                        },
                        "end": {
                            "line": 5,
                            "offset": 1
                        },
                        "newText": "/**\n * @param a\n * @param d\n */\n"
                    }
                ]
            }
        ]
    }

🙂 Expected behavior

Instead we should try to generate a more minimal edit so that editors can better preserve user's cursor position

Contributor Guide