Skip to content

testing: fix not apply configured editor options to result editor #251181

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

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Event } from '../../../../../base/common/event.js';
import { Iterable } from '../../../../../base/common/iterator.js';
import { Lazy } from '../../../../../base/common/lazy.js';
import { Disposable, DisposableStore, IDisposable, IReference, MutableDisposable, combinedDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';
import { ScrollEvent } from '../../../../../base/common/scrollable.js';
import { URI } from '../../../../../base/common/uri.js';
import { ICodeEditor, IDiffEditorConstructionOptions } from '../../../../../editor/browser/editorBrowser.js';
import { CodeEditorWidget } from '../../../../../editor/browser/widget/codeEditor/codeEditorWidget.js';
Expand All @@ -18,30 +19,31 @@ import { DiffEditorWidget } from '../../../../../editor/browser/widget/diffEdito
import { EmbeddedDiffEditorWidget } from '../../../../../editor/browser/widget/diffEditor/embeddedDiffEditorWidget.js';
import { MarkdownRenderer } from '../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
import { IDiffEditorOptions, IEditorOptions } from '../../../../../editor/common/config/editorOptions.js';
import { ITextModel } from '../../../../../editor/common/model.js';
import { IResolvedTextEditorModel, ITextModelService } from '../../../../../editor/common/services/resolverService.js';
import { peekViewResultsBackground } from '../../../../../editor/contrib/peekView/browser/peekView.js';
import { localize } from '../../../../../nls.js';
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
import { TerminalCapability } from '../../../../../platform/terminal/common/capabilities/capabilities.js';
import { TerminalCapabilityStore } from '../../../../../platform/terminal/common/capabilities/terminalCapabilityStore.js';
import { formatMessageForTerminal } from '../../../../../platform/terminal/common/terminalStrings.js';
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
import { IEditorConfiguration } from '../../../../browser/parts/editor/textEditor.js';
import { EditorModel } from '../../../../common/editor/editorModel.js';
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from '../../../../common/theme.js';
import { IViewDescriptorService, ViewContainerLocation } from '../../../../common/views.js';
import { CALL_STACK_WIDGET_HEADER_HEIGHT } from '../../../debug/browser/callStackWidget.js';
import { DetachedProcessInfo } from '../../../terminal/browser/detachedTerminal.js';
import { IDetachedTerminalInstance, ITerminalService } from '../../../terminal/browser/terminal.js';
import { getXtermScaledDimensions } from '../../../terminal/browser/xterm/xtermTerminal.js';
import { TERMINAL_BACKGROUND_COLOR } from '../../../terminal/common/terminalColorRegistry.js';
import { colorizeTestMessageInEditor } from '../testMessageColorizer.js';
import { InspectSubject, MessageSubject, TaskSubject, TestOutputSubject } from './testResultsSubject.js';
import { Testing } from '../../common/constants.js';
import { MutableObservableValue } from '../../common/observableValue.js';
import { ITaskRawOutput, ITestResult, ITestRunTaskResults, LiveTestResult, TestResultItemChangeReason } from '../../common/testResult.js';
import { ITestMessage, TestMessageType, getMarkId } from '../../common/testTypes.js';
import { ScrollEvent } from '../../../../../base/common/scrollable.js';
import { CALL_STACK_WIDGET_HEADER_HEIGHT } from '../../../debug/browser/callStackWidget.js';
import { ITextModel } from '../../../../../editor/common/model.js';
import { colorizeTestMessageInEditor } from '../testMessageColorizer.js';
import { InspectSubject, MessageSubject, TaskSubject, TestOutputSubject } from './testResultsSubject.js';


class SimpleDiffEditorModel extends EditorModel {
Expand Down Expand Up @@ -110,6 +112,35 @@ const diffEditorOptions: IDiffEditorConstructionOptions = {
diffAlgorithm: 'advanced',
};

function applyEditorMirrorOptions<T extends IEditorOptions>(base: T, cfg: IConfigurationService, update: (options: Partial<IEditorOptions>) => void) {
const immutable = new Set(Object.keys(base));
function applyCurrent() {
const configuration = cfg.getValue<IEditorConfiguration>('editor');

let changed = false;
const patch: Partial<IEditorOptions> = {};
for (const [key, value] of Object.entries(configuration)) {
if (!immutable.has(key) && (base as any)[key] !== value) {
(patch as any)[key] = value;
changed = true;
}
}

return changed ? patch : undefined;
}

Object.assign(base, applyCurrent());

return cfg.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('editor')) {
const patch = applyCurrent();
if (patch) {
update(patch);
Object.assign(base, patch);
}
}
});
}

export class DiffContentProvider extends Disposable implements IPeekOutputRenderer {
private readonly widget = this._register(new MutableDisposable<DiffEditorWidget>());
Expand All @@ -126,6 +157,7 @@ export class DiffContentProvider extends Disposable implements IPeekOutputRender
private readonly container: HTMLElement,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ITextModelService private readonly modelService: ITextModelService,
@IConfigurationService private readonly configurationService: IConfigurationService,
) {
super();
}
Expand All @@ -148,21 +180,32 @@ export class DiffContentProvider extends Disposable implements IPeekOutputRender

const model = this.model.value = new SimpleDiffEditorModel(original, modified);
if (!this.widget.value) {
this.widget.value = this.editor ? this.instantiationService.createInstance(
const options = { ...diffEditorOptions };
const listener = applyEditorMirrorOptions(
options,
this.configurationService,
u => editor.updateOptions(u)
);

const editor = this.widget.value = this.editor ? this.instantiationService.createInstance(
EmbeddedDiffEditorWidget,
this.container,
diffEditorOptions,
options,
{},
this.editor,
) : this.instantiationService.createInstance(
DiffEditorWidget,
this.container,
diffEditorOptions,
options,
{},
);

Event.once(editor.onDidDispose)(() => {
listener.dispose();
});

if (this.dimension) {
this.widget.value.layout(this.dimension);
editor.layout(this.dimension);
}
}

Expand Down Expand Up @@ -191,6 +234,7 @@ export class DiffContentProvider extends Disposable implements IPeekOutputRender
editor.getOriginalEditor().getContentHeight(),
editor.getModifiedEditor().getContentHeight()
);
editor.updateOptions({ scrollbar: { ...commonEditorOptions.scrollbar, handleMouseWheel: !hasMultipleFrames } });
this.helper = new ScrollHelper(hasMultipleFrames, height, dimensions.height);
return height;
}
Expand Down Expand Up @@ -293,6 +337,7 @@ export class PlainTextMessagePeek extends Disposable implements IPeekOutputRende
private readonly container: HTMLElement,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ITextModelService private readonly modelService: ITextModelService,
@IConfigurationService private readonly configurationService: IConfigurationService,
) {
super();
}
Expand All @@ -311,21 +356,32 @@ export class PlainTextMessagePeek extends Disposable implements IPeekOutputRende

const modelRef = this.model.value = await this.modelService.createModelReference(subject.messageUri);
if (!this.widget.value) {
this.widget.value = this.editor ? this.instantiationService.createInstance(
const options = { ...commonEditorOptions };
const listener = applyEditorMirrorOptions(
options,
this.configurationService,
u => editor.updateOptions(u)
);

const editor = this.widget.value = this.editor ? this.instantiationService.createInstance(
EmbeddedCodeEditorWidget,
this.container,
commonEditorOptions,
options,
{},
this.editor,
) : this.instantiationService.createInstance(
CodeEditorWidget,
this.container,
commonEditorOptions,
options,
{ isSimpleWidget: true }
);

Event.once(editor.onDidDispose)(() => {
listener.dispose();
});

if (this.dimension) {
this.widget.value.layout(this.dimension);
editor.layout(this.dimension);
}
}

Expand Down Expand Up @@ -355,6 +411,8 @@ export class PlainTextMessagePeek extends Disposable implements IPeekOutputRende
editor.layout(dimensions);
const height = editor.getContentHeight();
this.helper = new ScrollHelper(hasMultipleFrames, height, dimensions.height);
editor.updateOptions({ scrollbar: { ...commonEditorOptions.scrollbar, handleMouseWheel: !hasMultipleFrames } });

return height;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ export class TestResultsViewContent extends Disposable {

if (provider.onDidContentSizeChange) {
this.currentSubjectStore.add(provider.onDidContentSizeChange(() => {
if (this.dimension && !this.isDoingLayoutUpdate) {
const width = this.splitView.getViewSize(SubView.Diff);
if (this.dimension && !this.isDoingLayoutUpdate && width !== -1) {
this.isDoingLayoutUpdate = true;
topFrame.height.set(provider.layout(this.dimension, hasMultipleFrames)!, undefined);
topFrame.height.set(provider.layout({ width, height: this.dimension.height }, hasMultipleFrames)!, undefined);
this.isDoingLayoutUpdate = false;
}
}));
Expand Down
Loading