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

Feature Request: generate imports when copying code between files #66236

Closed
Rhobal opened this issue Jan 8, 2019 · 8 comments
Closed

Feature Request: generate imports when copying code between files #66236

Rhobal opened this issue Jan 8, 2019 · 8 comments
Assignees
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues upstream-issue-linked This is an upstream issue that has been reported upstream
Milestone

Comments

@Rhobal
Copy link

Rhobal commented Jan 8, 2019

In eclipse Java editing, copying a code snippet from a class to another also automatically copies the imports required by the copied code.
Would be nice to have this in VS Code for typescript as well. Currently when I copy some code, I have to manually resolve the imports afterwards.

@vscodebot
Copy link

vscodebot bot commented Jan 8, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@mjbvz mjbvz self-assigned this Jan 8, 2019
@mjbvz mjbvz added feature-request Request for new features or functionality typescript Typescript support issues javascript JavaScript support issues labels Jan 14, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented May 22, 2019

Needs api proposed in #30066

@johnculviner
Copy link

This feature is amazing in Webstorm / IntelliJ. It's one of the biggest things I miss coming from there.

I was actually doing some research into how pasteboard works in macOS at least (and the metadata that can live in it. formatting etc.). It's complicated. I think it might be possible to keep that metadata in vscode though and make the implementation easier to be cross OS usable:

  • When you do a copy, the string goes into the "ANY_OS" clipboard.
  • VSCode simultaenteouly stores the AST metadata (or however it works, need to check that part out) about that code in memory in the vscode process along with the associated string.
  • If you paste that string in vscode, vscode looks to see if it has any metadata for that string stored in it's process. If it does it uses the stored metadata to do any applicable imports.

I might see if I can pull this off as I love the direction of vscode but I sorely need this to reach the productivity I've enjoyed in IntelliJ...

@olegKusov

This comment was marked as spam.

@IgnusG
Copy link

IgnusG commented Jan 8, 2022

I've been wondering about this every now and then and today finally decided to search for a way to do this on the web. This would really be a cool thing to have. I was actually thinking of simply triggering the import all missing modules code action after paste if that's somehow possible. Otherwise it's just a few more keystrokes but still ^^'

@Kogs

This comment was marked as spam.

@dongzhuoyao

This comment was marked as spam.

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 4, 2022

Opened microsoft/TypeScript#50187 to track this upstream

@mjbvz mjbvz closed this as completed Aug 4, 2022
@mjbvz mjbvz added the upstream-issue-linked This is an upstream issue that has been reported upstream label Aug 4, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

7 participants