mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-30 08:16:49 +00:00
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
14 lines
512 B
TypeScript
14 lines
512 B
TypeScript
// Mounted code editors holding keystrokes their change debounce has not yet written to
|
|
// `code`. Lets an operation about to move or read drafts make those keystrokes land first.
|
|
const pending = new Set<() => void>()
|
|
|
|
export function trackPendingKeystrokes(flush: () => void): () => void {
|
|
pending.add(flush)
|
|
return () => pending.delete(flush)
|
|
}
|
|
|
|
/** Write every editor's debounced keystrokes to its `code` now. */
|
|
export function flushPendingKeystrokes(): void {
|
|
for (const flush of [...pending]) flush()
|
|
}
|