If switching to a previously open buffer in the same view, keep it's old offset
This commit is contained in:
parent
8949347e2c
commit
8f6f329057
1 changed files with 7 additions and 3 deletions
|
@ -81,11 +81,15 @@ impl Editor {
|
|||
view.jumps.push(jump);
|
||||
view.doc = id;
|
||||
view.first_line = 0;
|
||||
let view_id = view.id;
|
||||
|
||||
let (view, doc) = self.current();
|
||||
|
||||
// initialize selection for view
|
||||
let doc = &mut self.documents[id];
|
||||
doc.selections.insert(view_id, Selection::point(0));
|
||||
let selection = doc.selections.entry(view.id).or_insert(Selection::point(0));
|
||||
// TODO: reuse align_view
|
||||
let pos = selection.cursor();
|
||||
let line = doc.text().char_to_line(pos);
|
||||
view.first_line = line.saturating_sub(view.area.height as usize / 2);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue