When I drag and drop any file to Visual Studio Code's explorer, it automatically opens this file in the editor. Are there any settings to turn off this behavior?
Usually, I work with large and heavy CSV, JSON, etc., so when these files open it can really slow down my computer, also because some extensions like text highlighting automatically try to parse the text, but until it realizes that it is too much content to do his job and shows a warning that it won't continue because of performance issues, it has already slowed down my computer.
Of course, I can just close fast enough the file before this happens, but sometimes the problem still occurs (and anyway it should be possible to disable this feature).
I cloned a source of vscode to find solution. This is what I found in the source, when dragging multiple files, nothing will open:
vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts:
// if we only add one file, just open it directly
if (resourceFileEdits.length === 1) {
const item = this.explorerService.findClosest(resourceFileEdits[0].newResource!);
if (item && !item.isDirectory) {
this.editorService.openEditor({ resource: item.resource, options: { pinned: true } });
}
}
this code placed in:
private async addResources(target: ExplorerItem, resources: URI[], token: CancellationToken): Promise<void> {
and called from handleExternalDrop function.
private async handleExternalDrop(target: ExplorerItem, originalEvent: DragEvent, token: CancellationToken): Promise<void> {
Of course, this is not a solution if there is only one file.
And you probably need to create a 4.6k + 1 issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With