(e: vs.TextDocumentChangeEvent)
| 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. |
no test coverage detected