|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import { KeyCode, KeyMod } from '../../../../../base/common/keyCodes.js';
|
7 |
| -import { Disposable } from '../../../../../base/common/lifecycle.js'; |
| 7 | +import { Disposable, DisposableStore } from '../../../../../base/common/lifecycle.js'; |
8 | 8 | import { localize2 } from '../../../../../nls.js';
|
9 | 9 | import { AccessibleViewProviderId } from '../../../../../platform/accessibility/browser/accessibleView.js';
|
10 | 10 | import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../../../../../platform/accessibility/common/accessibility.js';
|
@@ -147,21 +147,17 @@ registerTerminalAction({
|
147 | 147 | }
|
148 | 148 | ],
|
149 | 149 | run: async (c, accessor) => {
|
150 |
| - // If there are no active instances, then create a new terminal instance |
151 |
| - const activeInstance = await c.service.getActiveOrCreateInstance(); |
152 |
| - // Newly created instances will not have a shell type set yet |
153 |
| - // This will result in the command picker not showing up, so wait for it to be set |
154 |
| - if (!activeInstance.shellType) { |
| 150 | + let activeInstance = c.service.activeInstance; |
| 151 | + // If an instanec doesn't exist, create one and wait for shell type to be set |
| 152 | + if (!activeInstance) { |
| 153 | + const newInstance = activeInstance = await c.service.getActiveOrCreateInstance(); |
155 | 154 | await c.service.revealActiveTerminal();
|
156 |
| - const wasDisposedPrematurely = await new Promise<boolean>(resolve => { |
157 |
| - activeInstance.onDidChangeShellType(() => { |
158 |
| - resolve(false); |
159 |
| - }); |
160 |
| - activeInstance.onDisposed(() => { |
161 |
| - resolve(true); |
162 |
| - }); |
| 155 | + const store = new DisposableStore(); |
| 156 | + const wasDisposedPrematurely = await new Promise<boolean>(r => { |
| 157 | + store.add(newInstance.onDidChangeShellType(() => r(false))); |
| 158 | + store.add(newInstance.onDisposed(() => r(true))); |
163 | 159 | });
|
164 |
| - // If the instance was disposed before the shell type was set, then exit |
| 160 | + store.dispose(); |
165 | 161 | if (wasDisposedPrematurely) {
|
166 | 162 | return;
|
167 | 163 | }
|
|
0 commit comments