-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #199927: Fix terminal tab list drag/drop selection #211482
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -577,6 +577,7 @@ class TerminalTabsDragAndDrop extends Disposable implements IListDragAndDrop<ITe | |
constructor( | ||
@ITerminalService private readonly _terminalService: ITerminalService, | ||
@ITerminalGroupService private readonly _terminalGroupService: ITerminalGroupService, | ||
@IListService private readonly _listService: IListService, | ||
) { | ||
super(); | ||
this._primaryBackend = this._terminalService.getPrimaryBackend(); | ||
|
@@ -707,10 +708,27 @@ class TerminalTabsDragAndDrop extends Disposable implements IListDragAndDrop<ITe | |
} | ||
|
||
let focused = false; | ||
// Retrieve the currently active instance asynchronously | ||
let activeInstancePromise = this._terminalService.activeInstance; | ||
let setActiveInstance = async (instance: ITerminalInstance) => { | ||
const activeInstance = await activeInstancePromise; // Ensure the promise is resolved before comparison. | ||
Comment on lines
+711
to
+714
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (activeInstance === instance) { | ||
this._terminalService.setActiveInstance(instance); | ||
} | ||
}; | ||
|
||
for (const instance of sourceInstances) { | ||
let targetWasFocus = (targetInstance === this._terminalService.activeInstance); | ||
this._terminalGroupService.moveGroup(instance, targetInstance); | ||
if (!focused) { | ||
this._terminalService.setActiveInstance(instance); | ||
// Await the setActiveInstance call to keep the loop synchronous | ||
await setActiveInstance(instance); | ||
if (targetWasFocus) { | ||
if (targetIndex) | ||
this._listService.lastFocusedList?.setSelection([targetIndex]); | ||
else | ||
this._listService.lastFocusedList?.setSelection([0]); | ||
} | ||
Comment on lines
+726
to
+731
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes the problem when dragging the second, inactive tab to the top. But not when dragging the first, inactive tab to the bottom. |
||
focused = true; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bunch of lint warnings about using const instead of let