-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 dragging files in browser #14756
Conversation
6e24f8d
to
f111561
Compare
@msujew I have a strange behavior: when I drag a file into the editor area, it opens in a dirty text editor, as expected. But when I click on the close box, I only get two options: "Save" and "Cancel". I should have "Don't save", as well. |
@tsmaeder Cannot reproduce :/ Screen.Recording.2025-01-29.181928.mp4 |
The theia/packages/core/src/browser/saveable.ts Lines 360 to 374 in c8ae828
|
Here's what I do...looks like the untitled resource causes a "save as..." dialog. This is firefox on windows. 2025-01-29.20-38-23.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had "autosave" on for some reason 🤷
What it does
Adds a feature that wasn't originally included in #12065. We currently support dragging files from the OS explorer to the main area of Theia, which results in opening the exact file (via its original URI) that was dropped into the application.
This won't work in browser based Theia apps for obvious reasons. Instead, this PRs adjusts the behavior for non-Electron apps. We now simply read the file name and text data of the dropped file into an
untitled
resource that we then attempt to open. Reusinguntitled
resources has a few benefits, mainly that it automatically handles disposal in case the editor is closed and also that it has special behavior when it comes to saving the file (it will automatically open the "Save As..." dialog).How to test
vscode.dev
also struggles with that, so it's at least as good as VS Code.untitled
resource.Follow-ups
We could potentially also support non-text files later on.
Review checklist
Reminder for reviewers