settingsMerge.ts ×7

Frontier kind: Code frontier

unlabeled · c_8898369d1283

67 tests · 10783 LOC · 47 files · introduces 0 tests · 27 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges27 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1135 ranges10783 lines · 47 files · Browse complete extent
All tests (intent)
67 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 27 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/settingsMerge.ts 27 introduced LOC · 7 ranges

Open complete file

103
104 export function merge(originalLocalContent: string, originalRemoteContent: string, baseContent: string | null, ignoredSettings: string[], resolvedConflicts: { key: string; value: any | undefined }[], formattingOptions: FormattingOptions): IMergeResult {
106 > const localContentWithoutIgnoredSettings = updateIgnoredSettings(originalLocalContent, originalRemoteContent, ignoredSettings, formattingOptions);
107 > const localForwarded = baseContent !== localContentWithoutIgnoredSettings;
108 > const remoteForwarded = baseContent !== originalRemoteContent;
109 >
110 > /* no changes */
111 > if (!localForwarded && !remoteForwarded) {
112 return { conflictsSettings: [], localContent: null, remoteContent: null, hasConflicts: false };
113 }
114
115 /* local has changed and remote has not */
116 > if (localForwarded && !remoteForwarded) { settingsMerge.ts
117 return { conflictsSettings: [], localContent: null, remoteContent: localContentWithoutIgnoredSettings, hasConflicts: false };
118 }
119
120 /* remote has changed and local has not */
121 > if (remoteForwarded && !localForwarded) { settingsMerge.ts
122 return { conflictsSettings: [], localContent: updateIgnoredSettings(originalRemoteContent, originalLocalContent, ignoredSettings, formattingOptions), remoteContent: null, hasConflicts: false };
123 }
124
125 /* local is empty and not synced before */
126 > if (baseContent === null && isEmpty(originalLocalContent)) { settingsMerge.ts
127 const localContent = areSame(originalLocalContent, originalRemoteContent, ignoredSettings) ? null : updateIgnoredSettings(originalRemoteContent, originalLocalContent, ignoredSettings, formattingOptions);
128 return { conflictsSettings: [], localContent, remoteContent: null, hasConflicts: false };
134 const local = parse(originalLocalContent);
135 const remote = parse(originalRemoteContent);
136 > const base = baseContent ? parse(baseContent) : null; settingsMerge.ts
137 >
138 > const ignored = ignoredSettings.reduce((set, key) => { set.add(key); return set; }, new Set<string>());
139 > const localToRemote = compare(local, remote, ignored);
140 > const baseToLocal = compare(base, local, ignored);
141 > const baseToRemote = compare(base, remote, ignored);
142 >
143 > const conflicts: Map<string, IConflictSetting> = new Map<string, IConflictSetting>();
144 > const handledConflicts: Set<string> = new Set<string>();
145 > const handleConflict = (conflictKey: string): void => {
146 handledConflicts.add(conflictKey);
147 const resolvedConflict = resolvedConflicts.filter(({ key }) => key === conflictKey)[0];
153 }
154 };
156 > // Removed settings in Local
157 > for (const key of baseToLocal.removed.values()) {
158 // Conflict - Got updated in remote.
159 if (baseToRemote.updated.has(key)) {
246
247 const hasConflicts = conflicts.size > 0 || !areSame(localContent, remoteContent, ignoredSettings);
248 > const hasLocalChanged = hasConflicts || !areSame(localContent, originalLocalContent, []); settingsMerge.ts
249 > const hasRemoteChanged = hasConflicts || !areSame(remoteContent, originalRemoteContent, []);
250 > return { localContent: hasLocalChanged ? localContent : null, remoteContent: hasRemoteChanged ? remoteContent : null, conflictsSettings: [...conflicts.values()], hasConflicts };
251 > }
252
253 function areSame(localContent: string, remoteContent: string, ignoredSettings: string[]): boolean {