Skip to content

Commit

Permalink
fixing insert_char update of ts state
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Feb 17, 2025
1 parent 56317ee commit cfcfb73
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,11 @@ impl Buffer {
let idx = cur.idx;

if let Some(ts) = self.ts_state.as_mut() {
let len = deleted.as_ref().map(|s| s.chars().count()).unwrap_or(1);
let ch_old_end = min(dot.first_cur().idx + len, self.txt.len_chars());
ts.edit(idx, ch_old_end, idx, &self.txt);
if let Some(s) = deleted.as_ref() {
let len = s.chars().count();
let ch_old_end = min(dot.first_cur().idx + len, self.txt.len_chars());
ts.edit(idx, ch_old_end, idx, &self.txt);
}
}

self.txt.insert_char(idx, ch);
Expand Down

0 comments on commit cfcfb73

Please sign in to comment.