Fingerprint loaded source text so same-length edits invalidate geometry.
(text: string)
| 40 | |
| 41 | /** Fingerprint loaded source text so same-length edits invalidate geometry. */ |
| 42 | function sourceTextFingerprint(text: string) { |
| 43 | let hash = 2166136261; |
| 44 | |
| 45 | for (let index = 0; index < text.length; index += 1) { |
| 46 | hash ^= text.charCodeAt(index); |
| 47 | hash = Math.imul(hash, 16777619); |
| 48 | } |
| 49 | |
| 50 | return `${text.length}:${(hash >>> 0).toString(36)}`; |
| 51 | } |
| 52 | |
| 53 | /** Stable suffix that captures note content/order for the geometry cache key. */ |
| 54 | function notesCacheKey(visibleAgentNotes: VisibleAgentNote[]) { |