Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support "Move to file" code action #863

Open
@guillaumebrunerie

Description

@guillaumebrunerie

Typescript 5.1 introduced a new "Move to file" code action in June 2023 (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html#move-declarations-to-existing-files), allowing moving a declaration to an existing file.

I can’t manage to get it to show up in Emacs, it only shows the "Move to a new file" code action which is a different (older) one. Is it supported by typescript-language-server? Looking at the logs, Emacs doesn’t get the code action at all:

[Trace - 09:38:26 AM] Received response 'textDocument/codeAction - (84684)' in 2842ms.
Result: [
  {
    "title": "Move to a new file",
    "kind": "refactor.move",
    "command": {
      "title": "Move to a new file",
      "command": "_typescript.applyRefactoring",
      "arguments": [
        {
          "file": "[...]",
          "startLine": 48,
          "startOffset": 20,
          "endLine": 48,
          "endOffset": 20,
          "refactor": "Move to a new file",
          "action": "Move to a new file"
        }
      ]
    }
  },
  {
    "title": "Convert to named function",
    "kind": "refactor",
    "command": {
      "title": "Convert to named function",
      "command": "_typescript.applyRefactoring",
      "arguments": [
        {
          "file": "[...]",
          "startLine": 48,
          "startOffset": 20,
          "endLine": 48,
          "endOffset": 20,
          "refactor": "Convert arrow function or function expression",
          "action": "Convert to named function"
        }
      ]
    }
  }
]

It might also be that Emacs' lsp-mode doesn’t send the right capabilities, I guess, as it is a code action that requires showing a file picker of some sort.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions