rubrikinc / wachy

A UI for eBPF-based performance debugging
https://rubrikinc.github.io/wachy/
Other
551 stars 17 forks source link

Scroll to the traced function in the initial view #4

Closed fasterit closed 2 years ago

fasterit commented 2 years ago

For me the function traced is initially always one line out of sight as there are two header lines in the window:

Latency [╷ Frequency╷ [^]

─────────┴──────────┴─────

so scrolling one line more gets it in sight:

diff --git a/src/views.rs b/src/views.rs
index 5e60819..9d2bc77 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -182,10 +182,10 @@ pub fn set_source_view(
     }
     // Set this twice - once before to prevent out of bounds, second time to
     // ensure the table scrolls to the right place.
-    sview.set_selected_row(selected_line as usize - 1);
+    sview.set_selected_row(selected_line as usize - 2);
     sview.set_items(items);
     // TODO is second time necessary?
-    sview.set_selected_row(selected_line as usize - 1);
+    sview.set_selected_row(selected_line as usize - 2);
 }

 pub type FooterView = PaddedView<Layer<TextView>>;

/DLange

viveksjain commented 2 years ago

Yes I have observed this as well, the correct row is highlighted but it's one line out of sight (unless the function is near end of file). Although your proposed patch would display the line, it would end up selecting the one above. I'd prefer to fix the underlying issue and so have opened BonsaiDen/cursive_table_view#35