Skip to content

Commit a062004

Browse files
authored
Merge branch 'main' into tyriar/210663
2 parents 659cc37 + 3be6cd6 commit a062004

File tree

31 files changed

+1056
-551
lines changed

31 files changed

+1056
-551
lines changed

src/vs/base/common/equals.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,86 @@ export function equalsIfDefined<T>(v1: T | undefined, v2: T | undefined, equals:
3636
}
3737
return equals(v1, v2);
3838
}
39+
40+
/**
41+
* Drills into arrays (items ordered) and objects (keys unordered) and uses strict equality on everything else.
42+
*/
43+
export function structuralEquals<T>(a: T, b: T): boolean {
44+
if (a === b) {
45+
return true;
46+
}
47+
48+
if (Array.isArray(a) && Array.isArray(b)) {
49+
if (a.length !== b.length) {
50+
return false;
51+
}
52+
for (let i = 0; i < a.length; i++) {
53+
if (!structuralEquals(a[i], b[i])) {
54+
return false;
55+
}
56+
}
57+
return true;
58+
}
59+
60+
if (Object.getPrototypeOf(a) === Object.prototype && Object.getPrototypeOf(b) === Object.prototype) {
61+
const aObj = a as Record<string, unknown>;
62+
const bObj = b as Record<string, unknown>;
63+
const keysA = Object.keys(aObj);
64+
const keysB = Object.keys(bObj);
65+
const keysBSet = new Set(keysB);
66+
67+
if (keysA.length !== keysB.length) {
68+
return false;
69+
}
70+
71+
for (const key of keysA) {
72+
if (!keysBSet.has(key)) {
73+
return false;
74+
}
75+
if (!structuralEquals(aObj[key], bObj[key])) {
76+
return false;
77+
}
78+
}
79+
80+
return true;
81+
}
82+
83+
return false;
84+
}
85+
86+
/**
87+
* `getStructuralKey(a) === getStructuralKey(b) <=> structuralEquals(a, b)`
88+
* (assuming that a and b are not cyclic structures and nothing extends globalThis Array).
89+
*/
90+
export function getStructuralKey(t: unknown): string {
91+
return JSON.stringify(toNormalizedJsonStructure(t));
92+
}
93+
94+
let objectId = 0;
95+
const objIds = new WeakMap<object, number>();
96+
97+
function toNormalizedJsonStructure(t: unknown): unknown {
98+
if (Array.isArray(t)) {
99+
return t.map(toNormalizedJsonStructure);
100+
}
101+
102+
if (t && typeof t === 'object') {
103+
if (Object.getPrototypeOf(t) === Object.prototype) {
104+
const tObj = t as Record<string, unknown>;
105+
const res: Record<string, unknown> = Object.create(null);
106+
for (const key of Object.keys(tObj).sort()) {
107+
res[key] = toNormalizedJsonStructure(tObj[key]);
108+
}
109+
return res;
110+
} else {
111+
let objId = objIds.get(t);
112+
if (objId === undefined) {
113+
objId = objectId++;
114+
objIds.set(t, objId);
115+
}
116+
// Random string to prevent collisions
117+
return objId + '----2b76a038c20c4bcc';
118+
}
119+
}
120+
return t;
121+
}

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'vs/editor/browser/services/hoverService/hoverService';
1515
import * as strings from 'vs/base/common/strings';
1616
import * as dom from 'vs/base/browser/dom';
1717
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
18-
import { Emitter, Event } from 'vs/base/common/event';
18+
import { Emitter, Event, IValueWithChangeEvent, ValueWithChangeEvent } from 'vs/base/common/event';
1919
import { ResolvedKeybinding, KeyCodeChord, Keybinding, decodeKeybinding } from 'vs/base/common/keybindings';
2020
import { IDisposable, IReference, ImmortalReference, toDisposable, DisposableStore, Disposable, combinedDisposable } from 'vs/base/common/lifecycle';
2121
import { OS, isLinux, isMacintosh } from 'vs/base/common/platform';
@@ -88,7 +88,7 @@ import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
8888
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
8989
import { DefaultConfiguration } from 'vs/platform/configuration/common/configurations';
9090
import { WorkspaceEdit } from 'vs/editor/common/languages';
91-
import { AccessibilitySignal, IAccessibilitySignalService, Sound } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
91+
import { AccessibilitySignal, AccessibilityModality, IAccessibilitySignalService, Sound } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
9292
import { LogService } from 'vs/platform/log/common/logService';
9393
import { getEditorFeatures } from 'vs/editor/common/editorFeatures';
9494
import { onUnexpectedError } from 'vs/base/common/errors';
@@ -1079,6 +1079,10 @@ class StandaloneAccessbilitySignalService implements IAccessibilitySignalService
10791079
async playSignals(cues: AccessibilitySignal[]): Promise<void> {
10801080
}
10811081

1082+
getEnabledState(signal: AccessibilitySignal, userGesture: boolean, modality?: AccessibilityModality | undefined): IValueWithChangeEvent<boolean> {
1083+
return ValueWithChangeEvent.const(false);
1084+
}
1085+
10821086
isSoundEnabled(cue: AccessibilitySignal): boolean {
10831087
return false;
10841088
}
@@ -1091,10 +1095,6 @@ class StandaloneAccessbilitySignalService implements IAccessibilitySignalService
10911095
return Event.None;
10921096
}
10931097

1094-
onAnnouncementEnabledChanged(cue: AccessibilitySignal): Event<void> {
1095-
return Event.None;
1096-
}
1097-
10981098
async playSound(cue: Sound, allowManyInParallel?: boolean | undefined): Promise<void> {
10991099
}
11001100
playSignalLoop(cue: AccessibilitySignal): IDisposable {

src/vs/platform/accessibility/common/accessibility.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ export function isAccessibilityInformation(obj: any): obj is IAccessibilityInfor
4848
&& (typeof obj.role === 'undefined' || typeof obj.role === 'string');
4949
}
5050

51+
export const ACCESSIBLE_VIEW_SHOWN_STORAGE_PREFIX = 'ACCESSIBLE_VIEW_SHOWN_';

0 commit comments

Comments
 (0)