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

Add import on file drop / file copy paste #50170

Open
mjbvz opened this issue Aug 3, 2022 · 1 comment
Open

Add import on file drop / file copy paste #50170

mjbvz opened this issue Aug 3, 2022 · 1 comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Aug 3, 2022

Suggestion

From microsoft/vscode#5240

πŸ” Search Terms

  • drop
  • dnd
  • import
  • require

⭐ Suggestion

When I drag and drop a file from VS Code's explorer into the top of my TypeScript code, it should insert an import statement

For example if I have the workspace:

index.ts
sub/
    other.ts

And I drop other.ts into index.ts, it should insert:

import $1 from './sub/other'; // here $1 is where the cursor should be after the drop

Other cases

  • I should be able to drag and drop multiple files to create multiple imports

  • Possible: If I drop the file into somewhere else in the file, we should instead insert an import expression

  • The added import path should take into account TypeScript's path resolution logic

  • This also should apply when copy and pasting a file into the editor

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Experience Enhancement Noncontroversial enhancements labels Aug 3, 2022
@mjbvz mjbvz changed the title Add import on file drop Add import on file drop / file copy paste Aug 4, 2022
@DanielRosenwasser
Copy link
Member

Related is #50187, but I guess is not the same. I suppose this needs a custom TSServer command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants