EditView: move cursor on content change

To the end of the content.
This commit is contained in:
Alexandre Bury 2016-09-01 11:37:03 -07:00
parent 53178a2d6d
commit d51772f714
2 changed files with 3 additions and 6 deletions

View File

@ -348,10 +348,7 @@ impl Cursive {
/// # }
/// ```
pub fn find<V: View + Any>(&mut self, sel: &view::Selector) -> Option<&mut V> {
match self.find_any(sel) {
None => None,
Some(b) => b.downcast_mut::<V>(),
}
self.find_any(sel).and_then(|b| b.downcast_mut::<V>())
}
/// Convenient method to use `find` with a `view::Selector::Id`.

View File

@ -166,9 +166,9 @@ impl EditView {
/// Replace the entire content of the view with the given one.
pub fn set_content(&mut self, content: &str) {
self.offset = 0;
self.cursor = 0;
self.content = Rc::new(content.to_string());
self.offset = 0;
self.set_cursor(content.len());
}
/// Get the current text.