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 drop into editor #70
Support drop into editor #70
Conversation
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.
Thanks @randomVariable2000 for the change request. Did you test the code ? I can't seem to make it work in my instance. I keep dropping with no result. I also left some changes I'd see necessary before merging the code.
src/extension.ts
Outdated
@@ -523,6 +523,37 @@ export function activate(context: vscode.ExtensionContext) { | |||
context.subscriptions.push(vscode.commands.registerCommand(commands.CommandsConsts.globalImportSnippets, | |||
async _ => handleCommand(() => commands.importSnippets(snippetsProvider)) | |||
)); | |||
|
|||
context.subscriptions.push(vscode.languages.registerDocumentDropEditProvider({ language: '*', scheme: '*'}, new class DropEditorProvider implements vscode.DocumentDropEditProvider { |
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.
you can use anonymous class here, replace new class DropEditorProvider implements vscode.DocumentDropEditProvider {}
with simple {}
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.
Done.
Thanks for reviewing this pull request! I had test the code. It work in my instance. If you did, could you provide some test cases that do not work? |
1528940
to
e3284d3
Compare
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.
The new code is working as expected. Thanks for the changes, I did update the code slightly to use the default mimetype, I'll merge it once you apply what I put in comments. Many thanks !
src/provider/snippetsProvider.ts
Outdated
@@ -8,11 +8,12 @@ import { SnippetService } from '../service/snippetService'; | |||
export class SnippetsProvider implements vscode.TreeDataProvider<Snippet>, vscode.TreeDragAndDropController<Snippet> { | |||
constructor(private _snippetService: SnippetService, private _extensionPath: string) { } | |||
|
|||
dropMimeTypes: readonly string[] = ['application/vnd.code.tree.snippetsProvider']; | |||
dropMimeTypes: readonly string[] = ['application/vnd.code.tree.snippetsProvider', 'text/uri-list']; |
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.
we won't need new mime type, we can use default one application/vnd.code.tree.snippetsProvider
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.
Done.
e3284d3
to
9f78898
Compare
9f78898
to
d742d56
Compare
Thanks @randomVariable2000 for your contribution, this will help future users a lot. |
Thanks. |
#63