-
Notifications
You must be signed in to change notification settings - Fork 39.3k
Terminal: add move tab up/down and kill terminals below #309084
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
Open
iliazlobin
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
iliazlobin:terminal-move-tab-kill-below
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
747f736
terminal: add move tab up/down and kill terminals below
7268776
address review: resolve group from context args, snapshot instances b…
4d0e8ba
remove Move Tab Up/Down from context menu, keep only Kill Terminals B…
f8e1378
Merge remote-tracking branch 'origin/main' into terminal-move-tab-kil…
8a5e82b
address review: unit tests, last-tab when clause, fix args fallback
9617bea
limit concurrent terminal disposal to 5 at a time in killGroupsBelow
1909a59
Merge branch 'main' into terminal-move-tab-kill-below
iliazlobin fcb003e
Merge branch 'main' into terminal-move-tab-kill-below
iliazlobin d067c4e
Merge branch 'main' into terminal-move-tab-kill-below
iliazlobin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
src/vs/workbench/contrib/terminal/test/browser/terminalGroupService.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { deepStrictEqual, strictEqual } from 'assert'; | ||
| import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js'; | ||
| import { ITerminalGroup } from '../../browser/terminal.js'; | ||
| import { TerminalGroupService } from '../../browser/terminalGroupService.js'; | ||
| import { IViewsService } from '../../../../services/views/common/viewsService.js'; | ||
| import { TestViewsService, workbenchInstantiationService } from '../../../../test/browser/workbenchTestServices.js'; | ||
|
|
||
| function makeGroup(id: number): ITerminalGroup { | ||
| return { terminalInstances: [], id, setVisible: () => { } } as unknown as ITerminalGroup; | ||
| } | ||
|
|
||
| suite('Workbench - TerminalGroupService', () => { | ||
| const store = ensureNoDisposablesAreLeakedInTestSuite(); | ||
|
|
||
| let service: TerminalGroupService; | ||
|
|
||
| setup(() => { | ||
| const instantiationService = workbenchInstantiationService(undefined, store); | ||
| instantiationService.stub(IViewsService, new TestViewsService()); | ||
| service = store.add(instantiationService.createInstance(TerminalGroupService)); | ||
| }); | ||
|
|
||
| suite('moveGroupUp', () => { | ||
| test('moving the first group is a no-op', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupUp(a); | ||
| deepStrictEqual(service.groups, [a, b, c]); | ||
| }); | ||
|
|
||
| test('moving an unknown group is a no-op', () => { | ||
| const [a, b] = [makeGroup(1), makeGroup(2)]; | ||
| service.groups.push(a, b); | ||
| service.moveGroupUp(makeGroup(99)); | ||
| deepStrictEqual(service.groups, [a, b]); | ||
| }); | ||
|
|
||
| test('moving a middle group swaps positions correctly', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupUp(b); | ||
| deepStrictEqual(service.groups, [b, a, c]); | ||
| }); | ||
|
|
||
| test('moving the last group up swaps with previous', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupUp(c); | ||
| deepStrictEqual(service.groups, [a, c, b]); | ||
| }); | ||
|
|
||
| test('activeGroupIndex follows the moved group', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.activeGroupIndex = 1; // b is active | ||
| service.moveGroupUp(b); | ||
| strictEqual(service.activeGroupIndex, 0); | ||
| }); | ||
|
|
||
| test('activeGroupIndex updates when active group is displaced', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.activeGroupIndex = 0; // a is active, b moves up over it | ||
| service.moveGroupUp(b); | ||
| strictEqual(service.activeGroupIndex, 1); | ||
| }); | ||
| }); | ||
|
|
||
| suite('moveGroupDown', () => { | ||
| test('moving the last group is a no-op', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupDown(c); | ||
| deepStrictEqual(service.groups, [a, b, c]); | ||
| }); | ||
|
|
||
| test('moving an unknown group is a no-op', () => { | ||
| const [a, b] = [makeGroup(1), makeGroup(2)]; | ||
| service.groups.push(a, b); | ||
| service.moveGroupDown(makeGroup(99)); | ||
| deepStrictEqual(service.groups, [a, b]); | ||
| }); | ||
|
|
||
| test('moving a middle group swaps positions correctly', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupDown(b); | ||
| deepStrictEqual(service.groups, [a, c, b]); | ||
| }); | ||
|
|
||
| test('moving the first group down swaps with next', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.moveGroupDown(a); | ||
| deepStrictEqual(service.groups, [b, a, c]); | ||
| }); | ||
|
|
||
| test('activeGroupIndex follows the moved group', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.activeGroupIndex = 1; // b is active | ||
| service.moveGroupDown(b); | ||
| strictEqual(service.activeGroupIndex, 2); | ||
| }); | ||
|
|
||
| test('activeGroupIndex updates when active group is displaced', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| service.activeGroupIndex = 2; // c is active, b moves down over it | ||
| service.moveGroupDown(b); | ||
| strictEqual(service.activeGroupIndex, 1); | ||
| }); | ||
| }); | ||
|
|
||
| suite('getGroupsBelow', () => { | ||
| test('returns empty array for unknown group', () => { | ||
| const [a, b] = [makeGroup(1), makeGroup(2)]; | ||
| service.groups.push(a, b); | ||
| deepStrictEqual(service.getGroupsBelow(makeGroup(99)), []); | ||
| }); | ||
|
|
||
| test('returns empty array for the last group', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| deepStrictEqual(service.getGroupsBelow(c), []); | ||
| }); | ||
|
|
||
| test('returns all groups below a middle group', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| deepStrictEqual(service.getGroupsBelow(b), [c]); | ||
| }); | ||
|
|
||
| test('returns all groups below the first group', () => { | ||
| const [a, b, c] = [makeGroup(1), makeGroup(2), makeGroup(3)]; | ||
| service.groups.push(a, b, c); | ||
| deepStrictEqual(service.getGroupsBelow(a), [b, c]); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.