Skip to content

Commit

Permalink
fix: reimplementing horizontal scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed May 12, 2024
1 parent d0111a5 commit 6a03594
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tui/src/components/api_explorer/req_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,22 @@ impl<'re> ReqEditor<'re> {
.col()
.saturating_sub(self.col_scroll)
.eq(&0)
.then(|| self.col_scroll = self.col_scroll.saturating_sub(1));
.then(|| {
self.col_scroll = self
.col_scroll
.saturating_sub(self.col_scroll.saturating_sub(self.cursor.col()))
});

self.cursor
.col()
.saturating_sub(self.col_scroll)
.gt(&self.layout.content_pane.width.sub(1).into())
.then(|| {
self.col_scroll = self
.cursor
.col()
.sub(self.layout.content_pane.width.sub(1) as usize)
});
}

fn jump_to_empty_line_below(&mut self) {
Expand Down Expand Up @@ -419,6 +434,7 @@ impl<'re> ReqEditor<'re> {
fn delete_word_backwards(&mut self) {
let walked = self.body.delete_word_backwards(&self.cursor);
self.cursor.move_left(walked);
self.maybe_scroll_view();
}

fn insert_char(&mut self, c: char) {
Expand Down Expand Up @@ -534,6 +550,7 @@ impl<'re> ReqEditor<'re> {

fn move_left(&mut self) {
self.cursor.move_left(1);
self.maybe_scroll_view();
}

fn move_down(&mut self) {
Expand Down

0 comments on commit 6a03594

Please sign in to comment.