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

Support drop into editor #70

Merged

Conversation

tianxiang24
Copy link
Contributor

#63

Copy link
Owner

@tahabasri tahabasri left a 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 Show resolved Hide resolved
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 {
Copy link
Owner

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 {}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/extension.ts Outdated Show resolved Hide resolved
@tianxiang24
Copy link
Contributor Author

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.

Thanks for reviewing this pull request! I had test the code. It work in my instance.
Can I ask if you held down the 'left shift' key when dropping the snippets?

image

If you did, could you provide some test cases that do not work?

@tianxiang24 tianxiang24 force-pushed the feat/support-drop-into-editor branch from 1528940 to e3284d3 Compare May 5, 2023 03:53
Copy link
Owner

@tahabasri tahabasri left a 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/extension.ts Show resolved Hide resolved
@@ -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'];
Copy link
Owner

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/provider/snippetsProvider.ts Outdated Show resolved Hide resolved
src/provider/snippetsProvider.ts Outdated Show resolved Hide resolved
@tianxiang24 tianxiang24 force-pushed the feat/support-drop-into-editor branch from e3284d3 to 9f78898 Compare May 6, 2023 03:37
@tianxiang24 tianxiang24 force-pushed the feat/support-drop-into-editor branch from 9f78898 to d742d56 Compare May 6, 2023 03:40
@tahabasri tahabasri merged commit dcb0852 into tahabasri:main May 6, 2023
1 check passed
@tahabasri
Copy link
Owner

Thanks @randomVariable2000 for your contribution, this will help future users a lot.

@tianxiang24
Copy link
Contributor Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants