Skip to content

add damage tracking to vt#792

Merged
aymanbagabas merged 4 commits into
charmbracelet:mainfrom
taigrr:vt/damage-tracking
Mar 4, 2026
Merged

add damage tracking to vt#792
aymanbagabas merged 4 commits into
charmbracelet:mainfrom
taigrr:vt/damage-tracking

Conversation

@taigrr

@taigrr taigrr commented Mar 4, 2026

Copy link
Copy Markdown
Contributor
  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

I reviewed #652 before submitting this, but that PR relies on ultraviolet functionality that's since been removed.

This implementation is (probably?) better now with the new ultraviolet:

• Pre-allocated slice, no per-event allocations
• Simple min/max tracking per line
• No callback overhead

Missing a few things, like scroll direction, though.

@codecov

codecov Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.28%. Comparing base (50d5c24) to head (742b12b).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
vt/screen.go 50.00% 8 Missing ⚠️
vt/csi_mode.go 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (50d5c24) and HEAD (742b12b). Click for more details.

HEAD has 88 uploads less than BASE
Flag BASE (50d5c24) HEAD (742b12b)
91 3
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #792       +/-   ##
===========================================
- Coverage   45.17%   34.28%   -10.90%     
===========================================
  Files         193       20      -173     
  Lines       13807     1709    -12098     
===========================================
- Hits         6238      586     -5652     
+ Misses       7189     1044     -6145     
+ Partials      380       79      -301     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread vt/screen.go Outdated

// ClearTouched clears the touched state.
func (s *Screen) ClearTouched() {
s.buf.Touched = make([]*uv.LineData, s.buf.Height())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that uv allocates this slices on calls to buf.Touch and buf.TouchLine etc. So I think this is enough

Suggested change
s.buf.Touched = make([]*uv.LineData, s.buf.Height())
s.buf.Touched = nil

Comment thread vt/screen.go Outdated
s.buf = uv.NewRenderBuffer(width, height)
} else {
s.buf.Resize(width, height)
s.buf.Touched = make([]*uv.LineData, height)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. Setting it to nil should be enough

Suggested change
s.buf.Touched = make([]*uv.LineData, height)
s.buf.Touched = nil

Comment thread vt/screen.go Outdated
Comment on lines +348 to +351
// touchAll marks all lines as touched.
func (s *Screen) touchAll() {
s.touchArea(s.buf.Bounds())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to setting the Touched slice to nil. The terminal renderer treat a nil Touched as all lines where "touched"

https://github.com/charmbracelet/uv/blob/a9960b7d0422a2c6253814b1ea2071795379eb12/terminal_renderer.go#L1201

@aymanbagabas aymanbagabas merged commit 7dd5c0a into charmbracelet:main Mar 4, 2026
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants