on master help sign in
Address some PR comments.
commit5ee6ba5b38ebeb86006bb2e42734a2285eb354df authorNathan Vegdahl <cessen@cessen.com> dateMon 26 Jul 2021, 10:51 (5 years ago) parent01247ac
2 files changed+7−8
helix-core/src/textobject.rs+3−4 helix-view/src/view.rs+4−4
helix-core/src/textobject.rs+3−4
@@ -32,10 +32,9 @@ fn find_word_boundary(slice: RopeSlice, mut pos: usize, direction: Direction) ->
3232 if category != prev_category && pos != 0 && pos != slice.len_chars() {
3333 return pos;
3434 } else {
35− if direction == Direction::Forward {
36− pos += 1;
37− } else {
38− pos = pos.saturating_sub(1);
35+ match direction {
36+ Direction::Forward => pos += 1,
37+ Direction::Backward => pos = pos.saturating_sub(1),
3938 }
4039 prev_category = category;
4140 }
helix-view/src/view.rs+4−4
@@ -92,17 +92,17 @@ impl View {
9292 let line = pos.row;
9393 let col = pos.col;
9494 let height = self.area.height.saturating_sub(1); // - 1 for statusline
95− let last_line = self.first_line + height as usize;
95+ let last_line = (self.first_line + height as usize).saturating_sub(1);
9696
9797 let scrolloff = PADDING.min(self.area.height as usize / 2); // TODO: user pref
9898
9999 // TODO: not ideal
100100 const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter
101− let last_col = self.first_col + (self.area.width as usize - OFFSET);
101+ let last_col = (self.first_col + self.area.width as usize).saturating_sub(OFFSET + 1);
102102
103− if line > last_line.saturating_sub(scrolloff + 1) {
103+ if line > last_line.saturating_sub(scrolloff) {
104104 // scroll down
105− self.first_line += line - (last_line.saturating_sub(scrolloff + 1));
105+ self.first_line += line - (last_line.saturating_sub(scrolloff));
106106 } else if line < self.first_line + scrolloff {
107107 // scroll up
108108 self.first_line = line.saturating_sub(scrolloff);