Skip to content

Support "Move to file" code action #863

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy