fix: keep the cursor at the end if it previously when diffing
This commit is contained in:
parent
2170a65c89
commit
22138671b4
1 changed files with 21 additions and 9 deletions
|
|
@ -542,16 +542,15 @@ where
|
||||||
state.is_pasting = None;
|
state.is_pasting = None;
|
||||||
state.dragging_state = None;
|
state.dragging_state = None;
|
||||||
}
|
}
|
||||||
|
let old_value = state
|
||||||
|
.value
|
||||||
|
.buffer()
|
||||||
|
.lines
|
||||||
|
.iter()
|
||||||
|
.map(|l| l.text())
|
||||||
|
.collect::<String>();
|
||||||
if state.is_secure != self.is_secure
|
if state.is_secure != self.is_secure
|
||||||
|| state
|
|| old_value != self.value.to_string()
|
||||||
.value
|
|
||||||
.buffer()
|
|
||||||
.lines
|
|
||||||
.iter()
|
|
||||||
.map(|l| l.text())
|
|
||||||
.collect::<String>()
|
|
||||||
!= self.value.to_string()
|
|
||||||
|| state
|
|| state
|
||||||
.label
|
.label
|
||||||
.buffer()
|
.buffer()
|
||||||
|
|
@ -585,6 +584,19 @@ where
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the previous state was at the end of the text, keep it there
|
||||||
|
let old_value = Value::new(&old_value);
|
||||||
|
if state.is_focused.is_some() {
|
||||||
|
match state.cursor.state(&old_value) {
|
||||||
|
cursor::State::Index(index) => {
|
||||||
|
if index == old_value.len() {
|
||||||
|
state.cursor.move_to(self.value.len());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let mut children: Vec<_> = self
|
let mut children: Vec<_> = self
|
||||||
.leading_icon
|
.leading_icon
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue