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

Support "Move to file" code action #863

Open
guillaumebrunerie opened this issue Feb 1, 2024 · 1 comment
Open

Support "Move to file" code action #863

guillaumebrunerie opened this issue Feb 1, 2024 · 1 comment

Comments

@guillaumebrunerie
Copy link

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.

@rchl
Copy link
Member

rchl commented Feb 1, 2024

It would have to be an opt-in and would require some custom glue code on the client.

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

No branches or pull requests

2 participants