diff --git a/ui/main.gd b/ui/main.gd index 91fa526..e4aa2bf 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -427,7 +427,7 @@ func _board_changed() -> void: view_rev += 1 edit_rev += 1 _update_collapse_all() - _update_endless_chip() + _schedule_endless_check() if mode == Mode.BUILD: refresh_live() @@ -3347,3 +3347,20 @@ func _run_undo_cli(args: PackedStringArray) -> void: ev.global_position = ev.position get_viewport().push_input(ev) await get_tree().process_frame + + +# ---------- Endless-loop check, debounced ---------- + +var _endless_timer: Timer + +## The endless-loop check walks the whole board (about 30 ms on an 800-card +## board), so edits schedule it to run once typing pauses instead of on every +## keystroke. +func _schedule_endless_check() -> void: + if _endless_timer == null: + _endless_timer = Timer.new() + _endless_timer.one_shot = true + _endless_timer.wait_time = 0.4 + _endless_timer.timeout.connect(_update_endless_chip) + add_child(_endless_timer) + _endless_timer.start()