🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@guillaumebrunerie
Copy link
Contributor

@guillaumebrunerie guillaumebrunerie commented Aug 31, 2025

This adds support for the "Move to file" code action, fixing #863.

This pull request does the following:

  • adds a supportsMoveToFileCodeAction initialization option so that the change is opt-in
  • this initialization option is then stored in a moveToFileCodeActionSupport flag in features
  • sets the includeInteractiveCodeActions flag to true in getRefactors, provided that the client does support the "Move to file" code action
  • filters out potential other interactive code actions in provideRefactors (as there could be other interactive code actions that would require separate opt-in)
  • throws an error in case applying a code action results in a body containing notApplicableReason (this is specific to interactive code actions as for instance "Move to file" may fail if you provide an invalid file name, which is only known when applying the code action).

See also emacs-lsp/lsp-mode#4866 for an implementation of it in Emacs' lsp-mode.

@guillaumebrunerie
Copy link
Contributor Author

I noticed that the client actually only receives the kind refactor.move instead of refactor.move.file because of the logic in the asKind function ("Move to file" starts with "Move"). I’m not sure if that should be fixed? It looks like many other code actions have a much more precise kind in tsserver, for instance "Infer function return type" has kind refactor.rewrite.function.returnType in tsserver but only refactor in typescript-language-server.

@rchl rchl merged commit 6cf230c into typescript-language-server:master Sep 15, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants