From c9040d0567113043893ab3c10e75f393860fc34b Mon Sep 17 00:00:00 2001 From: Benjamin Simmonds <44439583+benibenj@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:49:21 +0100 Subject: [PATCH] Fix Drag n Drop behavior in Open Editors with multiple groups (#203330) fix #203179 --- src/vs/base/browser/ui/list/listView.ts | 11 ++++++++++- src/vs/base/browser/ui/list/listWidget.ts | 3 +-- .../files/browser/views/openEditorsView.ts | 19 +++++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/vs/base/browser/ui/list/listView.ts b/src/vs/base/browser/ui/list/listView.ts index 4f8ab395ce6..5465520c08c 100644 --- a/src/vs/base/browser/ui/list/listView.ts +++ b/src/vs/base/browser/ui/list/listView.ts @@ -1221,7 +1221,7 @@ export class ListView implements IListView { feedback = distinct(feedback).filter(i => i >= -1 && i < this.length).sort((a, b) => a - b); feedback = feedback[0] === -1 ? [-1] : feedback; - const dragOverEffectPosition = typeof result !== 'boolean' && result.effect && result.effect.position ? result.effect.position : ListDragOverEffectPosition.Over; + let dragOverEffectPosition = typeof result !== 'boolean' && result.effect && result.effect.position ? result.effect.position : ListDragOverEffectPosition.Over; if (equalsDragFeedback(this.currentDragFeedback, feedback) && this.currentDragFeedbackPosition === dragOverEffectPosition) { return true; @@ -1244,6 +1244,15 @@ export class ListView implements IListView { throw new Error('Can\'t use multiple feedbacks with position different than \'over\''); } + // Make sure there is no flicker when moving between two items + // Always use the before feedback if possible + if (dragOverEffectPosition === ListDragOverEffectPosition.After) { + if (feedback[0] < this.length - 1) { + feedback[0] += 1; + dragOverEffectPosition = ListDragOverEffectPosition.Before; + } + } + for (const index of feedback) { const item = this.items[index]!; item.dropTarget = true; diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 4d61198158c..1a72e4e64d0 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -979,14 +979,13 @@ export class DefaultStyleController implements IStyleController { if (styles.listDropBetweenBackground) { content.push(` .monaco-list${suffix} .monaco-list-rows.drop-target-before .monaco-list-row:first-child::before, - .monaco-list${suffix} .monaco-list-row.drop-target-after + .monaco-list-row::before, .monaco-list${suffix} .monaco-list-row.drop-target-before::before { content: ""; position: absolute; top: 0px; left: 0px; width: 100%; height: 1px; background-color: ${styles.listDropBetweenBackground}; }`); content.push(` .monaco-list${suffix} .monaco-list-rows.drop-target-after .monaco-list-row:last-child::after, - .monaco-list${suffix} .monaco-list-row:last-child.drop-target-after::after { + .monaco-list${suffix} .monaco-list-row.drop-target-after::after { content: ""; position: absolute; bottom: 0px; left: 0px; width: 100%; height: 1px; background-color: ${styles.listDropBetweenBackground}; }`); diff --git a/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts b/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts index d38538f3e97..e4b7b0ca2c9 100644 --- a/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts +++ b/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts @@ -53,6 +53,7 @@ import { Schemas } from 'vs/base/common/network'; import { extUriIgnorePathCase } from 'vs/base/common/resources'; import { ILocalizedString } from 'vs/platform/action/common/action'; import { mainWindow } from 'vs/base/browser/window'; +import { EditorGroupView } from 'vs/workbench/browser/parts/editor/editorGroupView'; const $ = dom.$; @@ -727,7 +728,7 @@ class OpenEditorsDragAndDrop implements IListDragAndDrop