@@ -108,39 +108,50 @@ impl PendingUpdate {
108
108
109
109
let mut terminal = terminal. lock ( ) ;
110
110
111
- // Get the terminal's current damage and merge with incoming damage
111
+ // Get the terminal's current damage
112
112
let terminal_damage = terminal. peek_damage_event ( ) ;
113
- let merged_damage = match ( terminal_damage, & damage) {
114
- ( None , damage) => damage. clone ( ) ,
115
- ( Some ( term_damage) , damage) => Self :: merge_damages ( & term_damage, damage) ,
116
- } ;
117
113
118
114
// Create or update the snapshot
119
115
match & mut self . snapshot {
120
116
None => {
121
- // Create new snapshot
117
+ // Create new snapshot with merged terminal and incoming damage
118
+ let initial_damage = match ( terminal_damage, & damage) {
119
+ ( None , damage) => damage. clone ( ) ,
120
+ ( Some ( term_damage) , damage) => {
121
+ Self :: merge_damages ( & term_damage, damage)
122
+ }
123
+ } ;
124
+
122
125
self . snapshot = Some ( TerminalSnapshot {
123
126
colors : terminal. colors ,
124
127
display_offset : terminal. display_offset ( ) ,
125
128
blinking_cursor : terminal. blinking_cursor ,
126
129
visible_rows : terminal. visible_rows ( ) ,
127
130
cursor : terminal. cursor ( ) ,
128
- damage : merged_damage ,
131
+ damage : initial_damage ,
129
132
columns : terminal. columns ( ) ,
130
133
screen_lines : terminal. screen_lines ( ) ,
131
134
} ) ;
132
135
}
133
136
Some ( existing_snapshot) => {
134
- // Update existing snapshot with fresh terminal state but merge damage
137
+ // Update existing snapshot with fresh terminal state
135
138
existing_snapshot. colors = terminal. colors ;
136
139
existing_snapshot. display_offset = terminal. display_offset ( ) ;
137
140
existing_snapshot. blinking_cursor = terminal. blinking_cursor ;
138
141
existing_snapshot. visible_rows = terminal. visible_rows ( ) ;
139
142
existing_snapshot. cursor = terminal. cursor ( ) ;
140
- existing_snapshot. damage =
141
- Self :: merge_damages ( & existing_snapshot. damage , & merged_damage) ;
142
143
existing_snapshot. columns = terminal. columns ( ) ;
143
144
existing_snapshot. screen_lines = terminal. screen_lines ( ) ;
145
+
146
+ // Merge existing snapshot damage with incoming damage
147
+ existing_snapshot. damage =
148
+ Self :: merge_damages ( & existing_snapshot. damage , & damage) ;
149
+
150
+ // Also merge with terminal damage if present
151
+ if let Some ( term_damage) = terminal_damage {
152
+ existing_snapshot. damage =
153
+ Self :: merge_damages ( & existing_snapshot. damage , & term_damage) ;
154
+ }
144
155
}
145
156
}
146
157
@@ -242,6 +253,9 @@ mod tests {
242
253
let mut content = RenderableContent :: from_cursor_config ( & CursorConfig :: default ( ) ) ;
243
254
let terminal = create_test_terminal ( ) ;
244
255
256
+ // Reset terminal damage to start fresh
257
+ terminal. lock ( ) . reset_damage ( ) ;
258
+
245
259
// Add hint labels
246
260
content. hint_labels . push ( HintLabel {
247
261
position : Pos :: new ( Line ( 5 ) , Column ( 10 ) ) ,
@@ -313,6 +327,9 @@ mod tests {
313
327
let mut content = RenderableContent :: from_cursor_config ( & CursorConfig :: default ( ) ) ;
314
328
let terminal = create_test_terminal ( ) ;
315
329
330
+ // Reset terminal damage to start fresh
331
+ terminal. lock ( ) . reset_damage ( ) ;
332
+
316
333
// First invalidation with partial damage
317
334
let mut damaged_lines1 = BTreeSet :: new ( ) ;
318
335
damaged_lines1. insert ( LineDamage :: new ( 5 , true ) ) ;
0 commit comments