Skip to content

Commit 864f4f4

Browse files
authored
1 parent b9110d3 commit 864f4f4

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/vs/workbench/contrib/files/browser/views/openEditorsView.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class OpenEditorsView extends ViewPane {
6767
private dirtyCountElement!: HTMLElement;
6868
private listRefreshScheduler: RunOnceScheduler | undefined;
6969
private structuralRefreshDelay: number;
70+
private dnd: OpenEditorsDragAndDrop | undefined;
7071
private list: WorkbenchList<OpenEditor | IEditorGroup> | undefined;
7172
private listLabels: ResourceLabels | undefined;
7273
private needsRefresh = false;
@@ -198,13 +199,16 @@ export class OpenEditorsView extends ViewPane {
198199
if (this.listLabels) {
199200
this.listLabels.clear();
200201
}
202+
203+
this.dnd = new OpenEditorsDragAndDrop(this.sortOrder, this.instantiationService, this.editorGroupService);
204+
201205
this.listLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility });
202206
this.list = this.instantiationService.createInstance(WorkbenchList, 'OpenEditors', container, delegate, [
203207
new EditorGroupRenderer(this.keybindingService, this.instantiationService),
204208
new OpenEditorRenderer(this.listLabels, this.instantiationService, this.keybindingService, this.configurationService)
205209
], {
206210
identityProvider: { getId: (element: OpenEditor | IEditorGroup) => element instanceof OpenEditor ? element.getId() : element.id.toString() },
207-
dnd: new OpenEditorsDragAndDrop(this.instantiationService, this.editorGroupService),
211+
dnd: this.dnd,
208212
overrideStyles: {
209213
listBackground: this.getBackgroundColor()
210214
},
@@ -448,6 +452,9 @@ export class OpenEditorsView extends ViewPane {
448452
// Trigger a 'repaint' when decoration settings change or the sort order changed
449453
if (event.affectsConfiguration('explorer.decorations') || event.affectsConfiguration('explorer.openEditors.sortOrder')) {
450454
this.sortOrder = this.configurationService.getValue('explorer.openEditors.sortOrder');
455+
if (this.dnd) {
456+
this.dnd.sortOrder = this.sortOrder;
457+
}
451458
this.listRefreshScheduler?.schedule();
452459
}
453460
}
@@ -672,10 +679,18 @@ class OpenEditorRenderer implements IListRenderer<OpenEditor, IOpenEditorTemplat
672679

673680
class OpenEditorsDragAndDrop implements IListDragAndDrop<OpenEditor | IEditorGroup> {
674681

682+
private _sortOrder: 'editorOrder' | 'alphabetical' | 'fullPath';
683+
public set sortOrder(value: 'editorOrder' | 'alphabetical' | 'fullPath') {
684+
this._sortOrder = value;
685+
}
686+
675687
constructor(
688+
sortOrder: 'editorOrder' | 'alphabetical' | 'fullPath',
676689
private instantiationService: IInstantiationService,
677690
private editorGroupService: IEditorGroupsService
678-
) { }
691+
) {
692+
this._sortOrder = sortOrder;
693+
}
679694

680695
@memoize private get dropHandler(): ResourcesDropHandler {
681696
return this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: false });
@@ -724,6 +739,16 @@ class OpenEditorsDragAndDrop implements IListDragAndDrop<OpenEditor | IEditorGro
724739
}
725740
}
726741

742+
if (this._sortOrder !== 'editorOrder') {
743+
if (data instanceof ElementsDragAndDropData) {
744+
// No reordering supported when sorted
745+
return false;
746+
} else {
747+
// Allow droping files to open them
748+
return { accept: true, effect: { type: ListDragOverEffectType.Move }, feedback: [-1] } as IListDragOverReaction;
749+
}
750+
}
751+
727752
let dropEffectPosition: ListDragOverEffectPosition | undefined = undefined;
728753
switch (targetSector) {
729754
case ListViewTargetSector.TOP:

0 commit comments

Comments
 (0)