Skip to content

Commit e3cc677

Browse files
authored
Regression with drag-and-drop and recently opened list (fix microsoft#166130) (microsoft#166341)
1 parent a3c64da commit e3cc677

File tree

1 file changed

+17
-1
lines changed
  • src/vs/platform/dnd/browser

1 file changed

+17
-1
lines changed

src/vs/platform/dnd/browser/dnd.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DragMouseEvent } from 'vs/base/browser/mouseEvent';
88
import { coalesce } from 'vs/base/common/arrays';
99
import { DeferredPromise } from 'vs/base/common/async';
1010
import { VSBuffer } from 'vs/base/common/buffer';
11+
import { ResourceMap } from 'vs/base/common/map';
1112
import { parse } from 'vs/base/common/marshalling';
1213
import { Schemas } from 'vs/base/common/network';
1314
import { isWeb } from 'vs/base/common/platform';
@@ -121,7 +122,22 @@ export function extractEditorsDropData(e: DragEvent): Array<IDraggedResourceEdit
121122
}
122123
}
123124

124-
return editors;
125+
// Prevent duplicates: it is possible that we end up with the same
126+
// dragged editor multiple times because multiple data transfers
127+
// are being used (https://github.com/microsoft/vscode/issues/128925)
128+
129+
const coalescedEditors: IDraggedResourceEditorInput[] = [];
130+
const seen = new ResourceMap<boolean>();
131+
for (const editor of editors) {
132+
if (!editor.resource) {
133+
coalescedEditors.push(editor);
134+
} else if (!seen.has(editor.resource)) {
135+
coalescedEditors.push(editor);
136+
seen.set(editor.resource, true);
137+
}
138+
}
139+
140+
return coalescedEditors;
125141
}
126142

127143
export async function extractEditorsAndFilesDropData(accessor: ServicesAccessor, e: DragEvent): Promise<Array<IDraggedResourceEditorInput>> {

0 commit comments

Comments
 (0)