Address some PR comments.

imgbot
Nathan Vegdahl 3 years ago
parent 01247acf0c
commit 5ee6ba5b38

@ -32,10 +32,9 @@ fn find_word_boundary(slice: RopeSlice, mut pos: usize, direction: Direction) ->
if category != prev_category && pos != 0 && pos != slice.len_chars() { if category != prev_category && pos != 0 && pos != slice.len_chars() {
return pos; return pos;
} else { } else {
if direction == Direction::Forward { match direction {
pos += 1; Direction::Forward => pos += 1,
} else { Direction::Backward => pos = pos.saturating_sub(1),
pos = pos.saturating_sub(1);
} }
prev_category = category; prev_category = category;
} }

@ -92,17 +92,17 @@ impl View {
let line = pos.row; let line = pos.row;
let col = pos.col; let col = pos.col;
let height = self.area.height.saturating_sub(1); // - 1 for statusline let height = self.area.height.saturating_sub(1); // - 1 for statusline
let last_line = self.first_line + height as usize; let last_line = (self.first_line + height as usize).saturating_sub(1);
let scrolloff = PADDING.min(self.area.height as usize / 2); // TODO: user pref let scrolloff = PADDING.min(self.area.height as usize / 2); // TODO: user pref
// TODO: not ideal // TODO: not ideal
const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter
let last_col = self.first_col + (self.area.width as usize - OFFSET); let last_col = (self.first_col + self.area.width as usize).saturating_sub(OFFSET + 1);
if line > last_line.saturating_sub(scrolloff + 1) { if line > last_line.saturating_sub(scrolloff) {
// scroll down // scroll down
self.first_line += line - (last_line.saturating_sub(scrolloff + 1)); self.first_line += line - (last_line.saturating_sub(scrolloff));
} else if line < self.first_line + scrolloff { } else if line < self.first_line + scrolloff {
// scroll up // scroll up
self.first_line = line.saturating_sub(scrolloff); self.first_line = line.saturating_sub(scrolloff);

Loading…
Cancel
Save