diff --git a/src/tab.rs b/src/tab.rs index 255582f..78daf42 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -2244,13 +2244,17 @@ impl Tab { y: scroll_y as f32 }; - if let Some(offset) = self.virtual_cursor_offset { + if let Some(virtual_cursor_offset) = self.virtual_cursor_offset { new_offset = Point { - x: new_offset.x + offset.x, - y: new_offset.y + offset.y, + x: new_offset.x + virtual_cursor_offset.x, + y: new_offset.y + virtual_cursor_offset.y, }; } + if let Some(last_scroll_position) = self.last_scroll_position { + new_offset.x = (pos.x - last_scroll_position.x); + } + self.virtual_cursor_offset = Some(new_offset); self.last_scroll_offset = Some(new_offset);