|
|
@ -1282,6 +1282,8 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
|
|
|
|
.max(view.offset.row + scrolloff)
|
|
|
|
.max(view.offset.row + scrolloff)
|
|
|
|
.min(last_line.saturating_sub(scrolloff));
|
|
|
|
.min(last_line.saturating_sub(scrolloff));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If cursor needs moving, replace primary selection
|
|
|
|
|
|
|
|
if line != cursor.row {
|
|
|
|
let head = pos_at_coords(text, Position::new(line, cursor.col), true); // this func will properly truncate to line end
|
|
|
|
let head = pos_at_coords(text, Position::new(line, cursor.col), true); // this func will properly truncate to line end
|
|
|
|
|
|
|
|
|
|
|
|
let anchor = if doc.mode == Mode::Select {
|
|
|
|
let anchor = if doc.mode == Mode::Select {
|
|
|
@ -1290,8 +1292,13 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
|
|
|
|
head
|
|
|
|
head
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: only manipulate main selection
|
|
|
|
// replace primary selection with an empty selection at cursor pos
|
|
|
|
doc.set_selection(view.id, Selection::single(anchor, head));
|
|
|
|
let prim_sel = Range::new(anchor, head);
|
|
|
|
|
|
|
|
let mut sel = doc.selection(view.id).clone();
|
|
|
|
|
|
|
|
let idx = sel.primary_index();
|
|
|
|
|
|
|
|
sel = sel.replace(idx, prim_sel);
|
|
|
|
|
|
|
|
doc.set_selection(view.id, sel);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn page_up(cx: &mut Context) {
|
|
|
|
fn page_up(cx: &mut Context) {
|
|
|
|