MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / handleUpdate

Method handleUpdate

src/shared/vscode/trackers.ts:81–99  ·  view source on GitHub ↗
(e: vs.TextDocumentChangeEvent)

Source from the content-addressed store, hash-verified

79 }
80
81 private handleUpdate(e: vs.TextDocumentChangeEvent) {
82 if (e.document !== this.document)
83 return;
84
85 for (const offset of [...this.offsetMap.keys()]) {
86 // The key (offset) is the original offset, which we must use in the
87 // map to track the current offset.
88 // updateOffset takes the *value*, since we need to map the "current" (not
89 // original) value, and then updates the value in the map.
90 const currentOffset = this.offsetMap.get(offset)!;
91 const newOffset = this.updateOffset(currentOffset, e);
92 if (newOffset)
93 this.offsetMap.set(offset, newOffset);
94 else
95 this.offsetMap.delete(offset);
96 }
97
98 this.onOffsetsChangedEmitter.fire([e.document, this.offsetMap]);
99 }
100
101 private updateOffset(offset: number, change: vs.TextDocumentChangeEvent): number | undefined {
102 // If any edit spans us, consider us deleted.

Callers 1

constructorMethod · 0.95

Calls 5

updateOffsetMethod · 0.95
setMethod · 0.80
deleteMethod · 0.80
getMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected