Skip to content

Commit 34116a4

Browse files
authored
testing: fix expected vs actual widget does not close on ESC (microsoft#189202)
Fixes microsoft#188775
1 parent e1a9077 commit 34116a4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import { ICodeEditor, IDiffEditorConstructionOptions, isCodeEditor } from 'vs/ed
3434
import { EditorAction2 } from 'vs/editor/browser/editorExtensions';
3535
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
3636
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
37-
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
38-
import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
37+
import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2';
38+
import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget2 } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
3939
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
4040
import { Position } from 'vs/editor/common/core/position';
4141
import { Range } from 'vs/editor/common/core/range';
@@ -54,6 +54,7 @@ import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/con
5454
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
5555
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
5656
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
57+
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
5758
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
5859
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
5960
import { WorkbenchCompressibleObjectTree } from 'vs/platform/list/browser/listService';
@@ -801,16 +802,16 @@ class TestResultsPeek extends PeekViewWidget {
801802
private static lastHeightInLines?: number;
802803

803804
private readonly visibilityChange = this._disposables.add(new Emitter<boolean>());
804-
private readonly content: TestResultsViewContent;
805-
private scopedContextKeyService?: IContextKeyService;
805+
private content!: TestResultsViewContent;
806+
private scopedContextKeyService!: IContextKeyService;
806807
private dimension?: dom.Dimension;
807808
public current?: InspectSubject;
808809

809810
constructor(
810811
editor: ICodeEditor,
811812
@IThemeService themeService: IThemeService,
812813
@IPeekViewService peekViewService: IPeekViewService,
813-
@ITestingPeekOpener testingPeek: ITestingPeekOpener,
814+
@ITestingPeekOpener private readonly testingPeek: ITestingPeekOpener,
814815
@IContextKeyService private readonly contextKeyService: IContextKeyService,
815816
@IMenuService private readonly menuService: IMenuService,
816817
@IInstantiationService instantiationService: IInstantiationService,
@@ -820,7 +821,6 @@ class TestResultsPeek extends PeekViewWidget {
820821

821822
this._disposables.add(themeService.onDidColorThemeChange(this.applyTheme, this));
822823
this._disposables.add(this.onDidClose(() => this.visibilityChange.fire(false)));
823-
this.content = this._disposables.add(instantiationService.createInstance(TestResultsViewContent, editor, { historyVisible: testingPeek.historyVisible, showRevealLocationOnMessages: false }));
824824
this.applyTheme(themeService.getColorTheme());
825825
peekViewService.addExclusiveWidget(editor, this);
826826
}
@@ -841,11 +841,14 @@ class TestResultsPeek extends PeekViewWidget {
841841
if (!this.scopedContextKeyService) {
842842
this.scopedContextKeyService = this._disposables.add(this.contextKeyService.createScoped(container));
843843
TestingContextKeys.isInPeek.bindTo(this.scopedContextKeyService).set(true);
844+
const instaService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService]));
845+
this.content = this._disposables.add(instaService.createInstance(TestResultsViewContent, this.editor, { historyVisible: this.testingPeek.historyVisible, showRevealLocationOnMessages: false }));
844846
}
845847

846848
super._fillContainer(container);
847849
}
848850

851+
849852
protected override _fillHead(container: HTMLElement): void {
850853
super._fillHead(container);
851854

@@ -1025,7 +1028,7 @@ const isDiffable = (message: ITestMessage): message is ITestErrorMessage & { act
10251028
message.type === TestMessageType.Error && message.actual !== undefined && message.expected !== undefined;
10261029

10271030
class DiffContentProvider extends Disposable implements IPeekOutputRenderer {
1028-
private readonly widget = this._register(new MutableDisposable<DiffEditorWidget>());
1031+
private readonly widget = this._register(new MutableDisposable<DiffEditorWidget2>());
10291032
private readonly model = this._register(new MutableDisposable());
10301033
private dimension?: dom.IDimension;
10311034

@@ -1055,13 +1058,13 @@ class DiffContentProvider extends Disposable implements IPeekOutputRenderer {
10551058
const model = this.model.value = new SimpleDiffEditorModel(original, modified);
10561059
if (!this.widget.value) {
10571060
this.widget.value = this.editor ? this.instantiationService.createInstance(
1058-
EmbeddedDiffEditorWidget,
1061+
EmbeddedDiffEditorWidget2,
10591062
this.container,
10601063
diffEditorOptions,
10611064
{},
10621065
this.editor,
10631066
) : this.instantiationService.createInstance(
1064-
DiffEditorWidget,
1067+
DiffEditorWidget2,
10651068
this.container,
10661069
diffEditorOptions,
10671070
{},
@@ -1406,7 +1409,7 @@ function getOuterEditorFromDiffEditor(codeEditorService: ICodeEditorService): IC
14061409
const diffEditors = codeEditorService.listDiffEditors();
14071410

14081411
for (const diffEditor of diffEditors) {
1409-
if (diffEditor.hasTextFocus() && diffEditor instanceof EmbeddedDiffEditorWidget) {
1412+
if (diffEditor.hasTextFocus() && diffEditor instanceof EmbeddedDiffEditorWidget2) {
14101413
return diffEditor.getParentEditor();
14111414
}
14121415
}

0 commit comments

Comments
 (0)