-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Allow to add file reference with drag and drop. #5240
Comments
Yes, I wanted to do just that! How I miss this feature! It was so natural in Visual Studio. |
Is that feature coming in near future. Its really very tough to count nesting levels to create correct import path |
Is this feature ready now ? |
When will this feature be available?? |
I was also hoping to get this feature in a past release as well. |
Oh wow, this request was over two years ago... |
What's the standard way of inserting images into markdown in VSCode now? Still typing out all the commands? |
is there any extension that provides this functionality?? |
Also, it would be really great if there were options for this functionality in terms of how the paths showed up.
|
+1 |
Would be a dream to have this. Maybe next year or the year after that. Seriously, when I type the imports the stupid autocomplete tries to be smart and messes up completely, so I have to always search for a file where I used this import before, so I can copy paste it. |
+1 |
1 similar comment
+1 |
Homesite (from 2003) was capable of adding IMG/CSS/JS tags to HTML by simply dragging & dropping the resource file into the editor. (I've recently stopped using it because it hadn't been updated in some time, but I really miss this feature.) Apparently Atom has this feature in a plugin: FYI: This feature has been previously requested and both threads that I've found have been locked by collaborators. |
Would love to have this. |
+1 |
Still not implemented yet? This something i find myself wishing I can do very often. |
We need this feature! |
+1 |
2019 is ending without being able to drag a file into ide and have it import it |
+1 |
1 similar comment
+1 |
Welcome to 2020! Still nothing... +1 |
I wish for this feature multiple times a day |
+5 |
I think this issue goes along with an ability to import not just a file but also a function... Importing a file by dragging it
Importing a function and file by dragging it
EDIT: it just occurred to me that we do have: https://code.visualstudio.com/docs/languages/javascript#_auto-imports |
When I drag a file from the tree into the editor VSC just opens the file I dragged. I don't get an import statement added. |
@ people waiting for this. The old issues are not being watched. If somebody who wants this very very much creates a new issue, mark it as feature request and that issue receives 20 thumbs up, it will have a chance to be considered. I could do it myself but I learn to live with the limitations of VS Code. @jacobisaliveandwell VS Code itself is opinionated by having decided to open the file you just dropped. VS (the old one without code in its name) has decided to do the import for the file dropped and was so good. Opinionated is not a bad thing, without it, there would be no VS Code in the first place. |
Clearly there is interest in this, I'm not too familiar with the area but I don't see why we couldn't open on |
There once was a plugin that had this functionality and I used it all the time. |
@csicky Maybe I was too short. Sorry, let me try to be more clear. Obviously vscode has opinions, but opening the dropped item is standard across most applications, as are context specific overrides of this behavior. For example, if you drop a file in Chrome it will open a new tab and attempt to display/open the file, or optionally a site may implement drag-and-drop support. Similarly, vscode does not ship language specific IDEs like JetBrains, and it's not shipping with complex language support either. I don't see how one can implement this without diving into a lot of language specific questions (what languages support imports? how will they be formatted? do you import on the line dropped or at the top? should auto-formatters be triggered and if so, how? etc etc). Instead it'd be better to support whatever functionality is needed for individual language plugins to implement this feature. If this issue turns into that, then I apologize for getting in the way and can be ignored. |
Uh if it worked for javascript and typescript it'd cover 80% userbase. |
Yep, this sounds like a reasonable start. @jacobisaliveandwell some suggestions:
This behavior could probably be the same as IntelliSense auto imports.
I would propose a mix of the two:
@Tyriar a couple of questions: What did you mean by this? How would this allow for imports on drag?
Maybe one alternative that would allow the current behavior of VS Code to stay unchanged but to still enable development of this option would be my comment above (#5240 (comment)), what are your thoughts here?
|
@karlhorky I was just looking at the original post's gif where it was opening the file on
Something would need to happen like this or a setting since dragging now opens the file in the current/different editor group. A problem I see with a modifier though is that it's not very discoverable. Note this isn't really my area, my comment was mainly just responding to how to vote as that feeds into prioritization. |
It would also be interesting to be able to insert file references from clipboard like in the issue 106955 |
I think very good middle ground could be found here by making the drop event available to extensions while keeping the default behavior as-is. The drop handler in const isWorkspaceOpening = await this.doHandleDrop(untitledOrFileResources);
if (isWorkspaceOpening) {
return;
}
const isExtensionHandled = await this.extensionService.activateByEvent('onDrop', untitledOrFileResources);
if (isExtensionHandled) {
return;
} Architecturally, it would make sense to have the interface exposed to extensions be very minimal, accepting a list of resources and returning a boolean value indicating whether the extension wants to interrupt the default file opening behavior. onDrop(untitledOrFileResources: Array<IDraggedResource | IDraggedEditor>): boolean; This would allow both pass-through and overriding behaviors for extensions while limiting the API surface that VSCode exposes. |
So uh... been like 5 years now. Are we still waiting for this? |
@ericchase |
Updates? |
#142990 introduces api for VS Code 1.70 that lets extensions handle dropped files (either from the VS Code explorer, editor tabs, the OS, or other applications). This extension sample shows how to use this API This now needs to be implemented per-language by extensions. If you want to see this implemented in a given language, please file a feature request against the extension that provides support for that language |
@ElecTreeFrying amazing!! Thanks for creating this! 👏 |
It is very common use case when user wants to add reference of module file (external file) by dragging and dropping it to editor. But right now VScode is not supporting this feature. When user try to drag a file from the explorer window it is opening that file in the editor.
In the below screen shout you can compare Visual studio and VS code action for drag and drop.
The text was updated successfully, but these errors were encountered: