Skip to content

Commit

Permalink
Revert "testing: polish test coverage bar" (microsoft#212593)
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet authored May 13, 2024
1 parent 98e776c commit 4b1cc22
Show file tree
Hide file tree
Showing 24 changed files with 182 additions and 391 deletions.
2 changes: 1 addition & 1 deletion src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function _wrapAsStandardKeyboardEvent(handler: (e: IKeyboardEvent) => void): (e:
export const addStandardDisposableListener: IAddStandardDisposableListenerSignature = function addStandardDisposableListener(node: HTMLElement, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable {
let wrapHandler = handler;

if (type === 'click' || type === 'mousedown' || type === 'contextmenu') {
if (type === 'click' || type === 'mousedown') {
wrapHandler = _wrapAsStandardMouseEvent(getWindow(node), handler);
} else if (type === 'keydown' || type === 'keypress' || type === 'keyup') {
wrapHandler = _wrapAsStandardKeyboardEvent(handler);
Expand Down
10 changes: 0 additions & 10 deletions src/vs/editor/browser/editorBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,11 @@ export interface IOverlayWidgetPosition {
* The position preference for the overlay widget.
*/
preference: OverlayWidgetPositionPreference | IOverlayWidgetPositionCoordinates | null;

/**
* When set, stacks with other overlay widgets with the same preference,
* in an order determined by the ordinal value.
*/
stackOridinal?: number;
}
/**
* An overlay widgets renders on top of the text.
*/
export interface IOverlayWidget {
/**
* Event fired when the widget layout changes.
*/
onDidLayout?: Event<void>;
/**
* Render this overlay widget in a location where it could overflow the editor's view dom node.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/browser/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ export class View extends ViewEventHandler {
}

public layoutOverlayWidget(widgetData: IOverlayWidgetData): void {
const shouldRender = this._overlayWidgets.setWidgetPosition(widgetData.widget, widgetData.position);
const newPreference = widgetData.position ? widgetData.position.preference : null;
const shouldRender = this._overlayWidgets.setWidgetPosition(widgetData.widget, newPreference);
if (shouldRender) {
this._scheduleRender();
}
Expand Down
46 changes: 13 additions & 33 deletions src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import 'vs/css!./overlayWidgets';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import { IOverlayWidget, IOverlayWidgetPosition, IOverlayWidgetPositionCoordinates, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { IOverlayWidget, IOverlayWidgetPositionCoordinates, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart';
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/browser/view/renderingContext';
import { ViewContext } from 'vs/editor/common/viewModel/viewContext';
Expand All @@ -17,7 +17,6 @@ import * as dom from 'vs/base/browser/dom';
interface IWidgetData {
widget: IOverlayWidget;
preference: OverlayWidgetPositionPreference | IOverlayWidgetPositionCoordinates | null;
stack?: number;
domNode: FastDomNode<HTMLElement>;
}

Expand Down Expand Up @@ -110,17 +109,14 @@ export class ViewOverlayWidgets extends ViewPart {
this._updateMaxMinWidth();
}

public setWidgetPosition(widget: IOverlayWidget, position: IOverlayWidgetPosition | null): boolean {
public setWidgetPosition(widget: IOverlayWidget, preference: OverlayWidgetPositionPreference | IOverlayWidgetPositionCoordinates | null): boolean {
const widgetData = this._widgets[widget.getId()];
const preference = position ? position.preference : null;
const stack = position?.stackOridinal;
if (widgetData.preference === preference && widgetData.stack === stack) {
if (widgetData.preference === preference) {
this._updateMaxMinWidth();
return false;
}

widgetData.preference = preference;
widgetData.stack = stack;
this.setShouldRender();
this._updateMaxMinWidth();

Expand Down Expand Up @@ -154,37 +150,24 @@ export class ViewOverlayWidgets extends ViewPart {
this._context.viewLayout.setOverlayWidgetsMinWidth(maxMinWidth);
}

private _renderWidget(widgetData: IWidgetData, stackCoordinates: number[]): void {
private _renderWidget(widgetData: IWidgetData): void {
const domNode = widgetData.domNode;

if (widgetData.preference === null) {
domNode.setTop('');
return;
}

const maxRight = (2 * this._verticalScrollbarWidth) + this._minimapWidth;
if (widgetData.preference === OverlayWidgetPositionPreference.TOP_RIGHT_CORNER || widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
if (widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
domNode.setTop(0);
} else {
const widgetHeight = domNode.domNode.clientHeight;
domNode.setTop((this._editorHeight - widgetHeight - 2 * this._horizontalScrollbarHeight));
}

if (widgetData.stack !== undefined) {
domNode.setTop(stackCoordinates[widgetData.preference]);
stackCoordinates[widgetData.preference] += domNode.domNode.clientWidth;
} else {
domNode.setRight(maxRight);
}
if (widgetData.preference === OverlayWidgetPositionPreference.TOP_RIGHT_CORNER) {
domNode.setTop(0);
domNode.setRight((2 * this._verticalScrollbarWidth) + this._minimapWidth);
} else if (widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
const widgetHeight = domNode.domNode.clientHeight;
domNode.setTop((this._editorHeight - widgetHeight - 2 * this._horizontalScrollbarHeight));
domNode.setRight((2 * this._verticalScrollbarWidth) + this._minimapWidth);
} else if (widgetData.preference === OverlayWidgetPositionPreference.TOP_CENTER) {
domNode.setTop(0);
domNode.domNode.style.right = '50%';
if (widgetData.stack !== undefined) {
domNode.setTop(stackCoordinates[OverlayWidgetPositionPreference.TOP_CENTER]);
stackCoordinates[OverlayWidgetPositionPreference.TOP_CENTER] += domNode.domNode.clientHeight;
} else {
domNode.setTop(0);
}
} else {
const { top, left } = widgetData.preference;
const fixedOverflowWidgets = this._context.configuration.options.get(EditorOption.fixedOverflowWidgets);
Expand All @@ -211,12 +194,9 @@ export class ViewOverlayWidgets extends ViewPart {
this._domNode.setWidth(this._editorWidth);

const keys = Object.keys(this._widgets);
const stackCoordinates = Array.from({ length: OverlayWidgetPositionPreference.TOP_CENTER + 1 }, () => 0);
keys.sort((a, b) => (this._widgets[a].stack || 0) - (this._widgets[b].stack || 0));

for (let i = 0, len = keys.length; i < len; i++) {
const widgetId = keys[i];
this._renderWidget(this._widgets[widgetId], stackCoordinates);
this._renderWidget(this._widgets[widgetId]);
}
}
}
3 changes: 1 addition & 2 deletions src/vs/editor/browser/widget/diffEditor/diffEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import { HideUnchangedRegionsFeature } from 'vs/editor/browser/widget/diffEditor
import { MovedBlocksLinesFeature } from 'vs/editor/browser/widget/diffEditor/features/movedBlocksLinesFeature';
import { OverviewRulerFeature } from 'vs/editor/browser/widget/diffEditor/features/overviewRulerFeature';
import { RevertButtonsFeature } from 'vs/editor/browser/widget/diffEditor/features/revertButtonsFeature';
import { CSSStyle, ObservableElementSizeObserver, applyStyle, applyViewZones, readHotReloadableExport, translatePosition } from 'vs/editor/browser/widget/diffEditor/utils';
import { bindContextKey } from 'vs/platform/observable/common/platformObservableUtils';
import { CSSStyle, ObservableElementSizeObserver, applyStyle, applyViewZones, bindContextKey, readHotReloadableExport, translatePosition } from 'vs/editor/browser/widget/diffEditor/utils';
import { IDiffEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IDimension } from 'vs/editor/common/core/dimension';
import { Position } from 'vs/editor/common/core/position';
Expand Down
22 changes: 21 additions & 1 deletion src/vs/editor/browser/widget/diffEditor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { findLast } from 'vs/base/common/arraysFind';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { isHotReloadEnabled, registerHotReloadHandler } from 'vs/base/common/hotReload';
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IObservable, IReader, ISettableObservable, autorun, autorunHandleChanges, autorunOpts, autorunWithStore, observableSignalFromEvent, observableValue, transaction } from 'vs/base/common/observable';
import { IObservable, IReader, ISettableObservable, autorun, autorunHandleChanges, autorunOpts, autorunWithStore, observableFromEvent, observableSignalFromEvent, observableValue, transaction } from 'vs/base/common/observable';
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
import { ICodeEditor, IOverlayWidget, IViewZone } from 'vs/editor/browser/editorBrowser';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { DetailedLineRangeMapping } from 'vs/editor/common/diff/rangeMapping';
import { IModelDeltaDecoration } from 'vs/editor/common/model';
import { TextLength } from 'vs/editor/common/core/textLength';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyValue, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';

export function joinCombine<T>(arr1: readonly T[], arr2: readonly T[], keySelector: (val: T) => number, combine: (v1: T, v2: T) => T): readonly T[] {
if (arr1.length === 0) {
Expand Down Expand Up @@ -87,6 +89,17 @@ export function prependRemoveOnDispose(parent: HTMLElement, child: HTMLElement)
});
}

export function observableConfigValue<T>(key: string, defaultValue: T, configurationService: IConfigurationService): IObservable<T> {
return observableFromEvent(
(handleChange) => configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(key)) {
handleChange(e);
}
}),
() => configurationService.getValue<T>(key) ?? defaultValue,
);
}

export class ObservableElementSizeObserver extends Disposable {
private readonly elementSizeObserver: ElementSizeObserver;

Expand Down Expand Up @@ -427,6 +440,13 @@ function lengthBetweenPositions(position1: Position, position2: Position): TextL
}
}

export function bindContextKey<T extends ContextKeyValue>(key: RawContextKey<T>, service: IContextKeyService, computeValue: (reader: IReader) => T): IDisposable {
const boundKey = key.bindTo(service);
return autorunOpts({ debugName: () => `Set Context Key "${key.key}"` }, reader => {
boundKey.set(computeValue(reader));
});
}

export function filterWithPrevious<T>(arr: T[], filter: (cur: T, prev: T | undefined) => boolean): T[] {
let prev: T | undefined;
return arr.filter(cur => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
box-shadow: var(--vscode-editorStickyScroll-shadow) 0 3px 2px -2px;
z-index: 4;
background-color: var(--vscode-editorStickyScroll-background);
right: initial !important;
}

.monaco-editor .sticky-widget.peek {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { equals } from 'vs/base/common/arrays';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { ThemeIcon } from 'vs/base/common/themables';
import 'vs/css!./stickyScroll';
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
import { getColumnOfNodeOffset } from 'vs/editor/browser/viewParts/lines/viewLine';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
import { EditorLayoutInfo, EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
Expand Down Expand Up @@ -387,8 +387,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {

getPosition(): IOverlayWidgetPosition | null {
return {
preference: OverlayWidgetPositionPreference.TOP_CENTER,
stackOridinal: 10,
preference: null
};
}

Expand Down
9 changes: 0 additions & 9 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5387,21 +5387,12 @@ declare namespace monaco.editor {
* The position preference for the overlay widget.
*/
preference: OverlayWidgetPositionPreference | IOverlayWidgetPositionCoordinates | null;
/**
* When set, stacks with other overlay widgets with the same preference,
* in an order determined by the ordinal value.
*/
stackOridinal?: number;
}

/**
* An overlay widgets renders on top of the text.
*/
export interface IOverlayWidget {
/**
* Event fired when the widget layout changes.
*/
onDidLayout?: IEvent<void>;
/**
* Render this overlay widget in a location where it could overflow the editor's view dom node.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import { getStructuralKey } from 'vs/base/common/equals';
import { Event, IValueWithChangeEvent } from 'vs/base/common/event';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { FileAccess } from 'vs/base/common/network';
import { derived, observableFromEvent } from 'vs/base/common/observable';
import { derived, IObservable, observableFromEvent } from 'vs/base/common/observable';
import { ValueWithChangeEventFromObservable } from 'vs/base/common/observableInternal/utils';
import { localize } from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

export const IAccessibilitySignalService = createDecorator<IAccessibilitySignalService>('accessibilitySignalService');
Expand Down Expand Up @@ -202,7 +201,7 @@ export class AccessibilitySignalService extends Disposable implements IAccessibi
private readonly _signalConfigValue = new CachedFunction((signal: AccessibilitySignal) => observableConfigValue<{
sound: EnabledState;
announcement: EnabledState;
}>(signal.settingsKey, { sound: 'off', announcement: 'off' }, this.configurationService));
}>(signal.settingsKey, this.configurationService));

private readonly _signalEnabledState = new CachedFunction(
{ getCacheKey: getStructuralKey },
Expand Down Expand Up @@ -590,3 +589,13 @@ export class AccessibilitySignal {
});
}

export function observableConfigValue<T>(key: string, configurationService: IConfigurationService): IObservable<T> {
return observableFromEvent(
(handleChange) => configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(key)) {
handleChange(e);
}
}),
() => configurationService.getValue<T>(key),
);
}
30 changes: 0 additions & 30 deletions src/vs/platform/observable/common/platformObservableUtils.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { LineRange } from 'vs/workbench/contrib/mergeEditor/browser/model/lineRange';
import { DetailedLineRangeMapping, RangeMapping } from 'vs/workbench/contrib/mergeEditor/browser/model/mapping';
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';
import { observableConfigValue } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { LineRange as DiffLineRange } from 'vs/editor/common/core/lineRange';

export interface IMergeDiffComputer {
Expand Down
13 changes: 12 additions & 1 deletion src/vs/workbench/contrib/mergeEditor/browser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import { ArrayQueue, CompareResult } from 'vs/base/common/arrays';
import { onUnexpectedError } from 'vs/base/common/errors';
import { DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IObservable, autorunOpts } from 'vs/base/common/observable';
import { IObservable, autorunOpts, observableFromEvent } from 'vs/base/common/observable';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget';
import { IModelDeltaDecoration } from 'vs/editor/common/model';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';

export function setStyle(
Expand Down Expand Up @@ -155,3 +156,13 @@ export class PersistentStore<T> {
}
}

export function observableConfigValue<T>(key: string, defaultValue: T, configurationService: IConfigurationService): IObservable<T> {
return observableFromEvent(
(handleChange) => configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(key)) {
handleChange(e);
}
}),
() => configurationService.getValue<T>(key) ?? defaultValue,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { MenuId } from 'vs/platform/actions/common/actions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { DEFAULT_EDITOR_MAX_DIMENSIONS, DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
import { setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';
import { observableConfigValue, setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { MergeEditorViewModel } from 'vs/workbench/contrib/mergeEditor/browser/view/viewModel';

export abstract class CodeEditorView extends Disposable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ import { readTransientState, writeTransientState } from 'vs/workbench/contrib/co
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
import { IMergeEditorInputModel } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel';
import { MergeEditorModel } from 'vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel';
import { deepMerge, PersistentStore, thenIfNotDisposed } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';
import { deepMerge, observableConfigValue, PersistentStore, thenIfNotDisposed } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { BaseCodeEditorView } from 'vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView';
import { ScrollSynchronizer } from 'vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer';
import { MergeEditorViewModel } from 'vs/workbench/contrib/mergeEditor/browser/view/viewModel';
Expand Down
Loading

0 comments on commit 4b1cc22

Please sign in to comment.