Throttle TextChanged to drastically decrease delay for fast typers#5
Throttle TextChanged to drastically decrease delay for fast typers#5InsanityGod wants to merge 3 commits intojayugg:masterfrom
TextChanged to drastically decrease delay for fast typers#5Conversation
…nt to look into options that allow for larger throttles)
WalkthroughAdds a debounced two-step text-change flow to GuiElementTextArea: TextChanged now enqueues a main-thread task TextChangedBatched and sets a private debounce flag; TextChangedBatched recalculates auto-height/world bounds, calls base.TextChanged, and clears the flag. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant TA as GuiElementTextArea
participant UI as MainThread
participant Base as BaseGuiElement
User->>TA: Text input
TA->>TA: TextChanged()\n(check textChangedBatchedQueued)
alt not queued
TA->>TA: set textChangedBatchedQueued = true
TA->>UI: enqueue TextChangedBatched()
else queued
TA-->>User: return (debounced)
end
UI->>TA: TextChangedBatched()
rect rgba(230,245,255,0.5)
note over TA: If Autoheight enabled\nupdate auto-height bounds
TA->>TA: Recalculate world bounds
TA->>Base: base.TextChanged()
end
TA->>TA: textChangedBatchedQueued = false (finally)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
VTMLEditor/GuiElements/Vanilla/GuiElementTextArea.cs (1)
38-38: Consider adding a comment to explain the debounce mechanism.The field name
textChangeDelayeddoesn't fully convey the coalescing behavior where rapid text changes are batched together. A brief comment would help future maintainers understand the intent.Example:
+ // Prevents redundant text processing by batching rapid updates private bool textChangeDelayed;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
VTMLEditor/GuiElements/Vanilla/GuiElementTextArea.cs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
VTMLEditor/GuiElements/Vanilla/GuiElementTextArea.cs (2)
VTMLEditor/GuiElements/Vanilla/GuiElementEditableTextBase.cs (1)
TextChanged(552-557)VTMLEditor/GuiElements/Vanilla/GuiElementTextBase.cs (1)
GetMultilineTextHeight(49-52)
…nThreadTask`, not that it really matters as you'd have far bigger issues if that fails)
throttle text update, this was the simplest way to do it but might want to look into options that allow for larger throttles.
Summary by CodeRabbit
Bug Fixes
Performance