@@ -53,6 +53,7 @@ import { Schemas } from 'vs/base/common/network';
53
53
import { extUriIgnorePathCase } from 'vs/base/common/resources' ;
54
54
import { ILocalizedString } from 'vs/platform/action/common/action' ;
55
55
import { mainWindow } from 'vs/base/browser/window' ;
56
+ import { EditorGroupView } from 'vs/workbench/browser/parts/editor/editorGroupView' ;
56
57
57
58
const $ = dom . $ ;
58
59
@@ -727,7 +728,7 @@ class OpenEditorsDragAndDrop implements IListDragAndDrop<OpenEditor | IEditorGro
727
728
switch ( targetSector ) {
728
729
case ListViewTargetSector . TOP :
729
730
case ListViewTargetSector . CENTER_TOP :
730
- dropEffectPosition = ListDragOverEffectPosition . Before ; break ;
731
+ dropEffectPosition = ( _targetIndex === 0 && _targetElement instanceof EditorGroupView ) ? ListDragOverEffectPosition . After : ListDragOverEffectPosition . Before ; break ;
731
732
case ListViewTargetSector . CENTER_BOTTOM :
732
733
case ListViewTargetSector . BOTTOM :
733
734
dropEffectPosition = ListDragOverEffectPosition . After ; break ;
@@ -737,19 +738,29 @@ class OpenEditorsDragAndDrop implements IListDragAndDrop<OpenEditor | IEditorGro
737
738
}
738
739
739
740
drop ( data : IDragAndDropData , targetElement : OpenEditor | IEditorGroup | undefined , _targetIndex : number , targetSector : ListViewTargetSector | undefined , originalEvent : DragEvent ) : void {
740
- const group = targetElement instanceof OpenEditor ? targetElement . group : targetElement || this . editorGroupService . groups [ this . editorGroupService . count - 1 ] ;
741
+ let group = targetElement instanceof OpenEditor ? targetElement . group : targetElement || this . editorGroupService . groups [ this . editorGroupService . count - 1 ] ;
741
742
let targetEditorIndex = targetElement instanceof OpenEditor ? targetElement . group . getIndexOfEditor ( targetElement . editor ) : 0 ;
742
743
743
744
switch ( targetSector ) {
745
+ case ListViewTargetSector . TOP :
746
+ case ListViewTargetSector . CENTER_TOP :
747
+ if ( targetElement instanceof EditorGroupView && group . index !== 0 ) {
748
+ group = this . editorGroupService . groups [ group . index - 1 ] ;
749
+ targetEditorIndex = group . count ;
750
+ }
751
+ break ;
744
752
case ListViewTargetSector . BOTTOM :
745
753
case ListViewTargetSector . CENTER_BOTTOM :
746
- targetEditorIndex ++ ; break ;
754
+ if ( targetElement instanceof OpenEditor ) {
755
+ targetEditorIndex ++ ;
756
+ }
757
+ break ;
747
758
}
748
759
749
760
if ( data instanceof ElementsDragAndDropData ) {
750
761
for ( const oe of data . elements ) {
751
762
const sourceEditorIndex = oe . group . getIndexOfEditor ( oe . editor ) ;
752
- if ( sourceEditorIndex < targetEditorIndex ) {
763
+ if ( oe . group === group && sourceEditorIndex < targetEditorIndex ) {
753
764
targetEditorIndex -- ;
754
765
}
755
766
oe . group . moveEditor ( oe . editor , group , { index : targetEditorIndex , preserveFocus : true } ) ;
0 commit comments