mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 08:15:56 +01:00
Fix close tracking in browser API (#303304)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as vscode from 'vscode';
|
||||
import { window, ViewColumn } from 'vscode';
|
||||
import { window, commands, ViewColumn } from 'vscode';
|
||||
import { assertNoRpc, closeAllEditors } from '../utils';
|
||||
|
||||
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('vscode API - browser', () => {
|
||||
@@ -73,6 +73,16 @@ import { assertNoRpc, closeAllEditors } from '../utils';
|
||||
assert.strictEqual(window.browserTabs.length, countBefore - 1);
|
||||
});
|
||||
|
||||
test('Can move a browser tab to a new group and close it successfully', async () => {
|
||||
const tab = await window.openBrowserTab('about:blank');
|
||||
assert.ok(window.browserTabs.includes(tab));
|
||||
|
||||
await commands.executeCommand('workbench.action.moveEditorToNextGroup');
|
||||
|
||||
await tab.close();
|
||||
assert.ok(!window.browserTabs.includes(tab));
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region onDidOpenBrowserTab
|
||||
|
||||
@@ -41,11 +41,6 @@ export class MainThreadBrowsers extends Disposable implements MainThreadBrowsers
|
||||
this._track(e.editor);
|
||||
}
|
||||
}));
|
||||
this._register(this.editorService.onDidCloseEditor(e => {
|
||||
if (e.editor instanceof BrowserEditorInput) {
|
||||
this._knownBrowsers.deleteAndDispose(e.editor.id);
|
||||
}
|
||||
}));
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => this._syncActiveBrowserTab()));
|
||||
|
||||
// Initial sync
|
||||
@@ -102,9 +97,11 @@ export class MainThreadBrowsers extends Disposable implements MainThreadBrowsers
|
||||
this._proxy.$onDidChangeBrowserTabState(input.id, this._toDto(input));
|
||||
}));
|
||||
disposables.add(input.onWillDispose(() => {
|
||||
this._proxy.$onDidCloseBrowserTab(input.id);
|
||||
this._knownBrowsers.deleteAndDispose(input.id);
|
||||
}));
|
||||
disposables.add(toDisposable(() => {
|
||||
this._proxy.$onDidCloseBrowserTab(input.id);
|
||||
}));
|
||||
|
||||
this._knownBrowsers.set(input.id, { input, dispose: () => disposables.dispose() });
|
||||
this._proxy.$onDidOpenBrowserTab(this._toDto(input));
|
||||
|
||||
Reference in New Issue
Block a user