Skip to content

Commit

Permalink
Just use a deep equality library
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Feb 22, 2023
1 parent a60019f commit d8e83e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@theia/variable-resolver": "1.34.0",
"@theia/workspace": "1.34.0",
"@vscode/debugprotocol": "^1.51.0",
"fast-deep-equal": "^3.1.3",
"jsonc-parser": "^2.2.0",
"p-debounce": "^2.1.0"
},
Expand Down
16 changes: 4 additions & 12 deletions packages/debug/src/browser/breakpoint/breakpoint-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Emitter } from '@theia/core/lib/common';
import { StorageService } from '@theia/core/lib/browser';
import { Marker } from '@theia/markers/lib/common/marker';
import { MarkerManager } from '@theia/markers/lib/browser/marker-manager';
import * as deepEqual from 'fast-deep-equal';
import URI from '@theia/core/lib/common/uri';
import { SourceBreakpoint, BREAKPOINT_KIND, ExceptionBreakpoint, FunctionBreakpoint, BaseBreakpoint, InstructionBreakpoint } from './breakpoint-marker';

Expand Down Expand Up @@ -64,24 +65,15 @@ export class BreakpointManager extends MarkerManager<SourceBreakpoint> {
const added: SourceBreakpoint[] = [];
const removed: SourceBreakpoint[] = [];
const changed: SourceBreakpoint[] = [];
const oldMarkers = new Map(result.map(({ data }) => [data.id, data] as [string, SourceBreakpoint]));
const oldMarkers = new Map(result.map(({ data }) => [data.id, data]));
const ids = new Set<string>();
for (const newMarker of newMarkers) {
ids.add(newMarker.id);
const oldMarker = oldMarkers.get(newMarker.id);
if (!oldMarker) {
added.push(newMarker);
// @ts-ignore
} else {
const oldRawKeys = Object.keys(oldMarker.raw);
const newRawKeys = Object.keys(newMarker.raw);
if (
newRawKeys.length !== oldRawKeys.length
|| newRawKeys.some((key: keyof SourceBreakpoint['raw']) => newMarker.raw[key] !== oldMarker.raw[key])
|| Object.keys(newMarker).some((key: keyof SourceBreakpoint) => key !== 'raw' && newMarker[key] !== oldMarker[key])
) {
changed.push(newMarker);
}
} else if (!deepEqual(oldMarker, newMarker)) {
changed.push(newMarker);
}
}
for (const [id, data] of oldMarkers.entries()) {
Expand Down

0 comments on commit d8e83e3

Please sign in to comment.