sreepathi-ravikumar commited on
Commit
474aab3
·
verified ·
1 Parent(s): d2487a9

Update rust_highlight/src/lib.rs

Browse files
Files changed (1) hide show
  1. rust_highlight/src/lib.rs +5 -7
rust_highlight/src/lib.rs CHANGED
@@ -241,8 +241,9 @@ fn wrap_text_cv(text: &str, font: i32, default_font_scale: f64, default_thicknes
241
  cur = candidate;
242
  } else {
243
  if !cur.is_empty() {
244
- wrapped_lines.push(cur);
245
  styles.push(is_header);
 
246
  }
247
  let mut base_line_single = 0;
248
  let size_single = get_text_size(w, font, font_scale, thickness, &mut base_line_single).unwrap();
@@ -255,27 +256,24 @@ fn wrap_text_cv(text: &str, font: i32, default_font_scale: f64, default_thicknes
255
  if size_ch.width <= max_width {
256
  chunk = cand2;
257
  } else {
258
- wrapped_lines.push(chunk);
259
  styles.push(is_header);
260
  chunk = ch.to_string();
261
  }
262
  }
263
- if !chunk.is_empty() {
264
- cur = chunk;
265
- }
266
  } else {
267
  cur = w.to_string();
268
  }
269
  }
270
  }
271
  if !cur.is_empty() {
272
- wrapped_lines.push(cur);
273
  styles.push(is_header);
274
  }
275
  }
276
  (wrapped_lines, styles)
277
  }
278
-
279
  fn render_frame(
280
  visible_text: &str,
281
  pen_x: i32,
 
241
  cur = candidate;
242
  } else {
243
  if !cur.is_empty() {
244
+ wrapped_lines.push(cur.clone()); // FIX: Clone here
245
  styles.push(is_header);
246
+ cur.clear(); // FIX: Clear for reuse
247
  }
248
  let mut base_line_single = 0;
249
  let size_single = get_text_size(w, font, font_scale, thickness, &mut base_line_single).unwrap();
 
256
  if size_ch.width <= max_width {
257
  chunk = cand2;
258
  } else {
259
+ wrapped_lines.push(chunk.clone()); // FIX: Clone here
260
  styles.push(is_header);
261
  chunk = ch.to_string();
262
  }
263
  }
264
+ cur = chunk; // FIX: Move chunk to cur (this is fine)
 
 
265
  } else {
266
  cur = w.to_string();
267
  }
268
  }
269
  }
270
  if !cur.is_empty() {
271
+ wrapped_lines.push(cur); // FIX: Final push can move (no more use after)
272
  styles.push(is_header);
273
  }
274
  }
275
  (wrapped_lines, styles)
276
  }
 
277
  fn render_frame(
278
  visible_text: &str,
279
  pen_x: i32,