-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(buffer): track_caller for index_of #1046
Conversation
The caller put in the wrong x/y -> the caller is the cause. In the future get and get_mut should return Option but thats a bigger change.
I agree with this change. Can we open an issue for this to track it? |
#1011 is less specific to Buffer but includes this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these might give some messages that might not make contextual sense, but I'm not sure. Perhaps a few unit tests for this would help clarify. I'd want to see them from the perspective of a direct call (i.e. what panic message will a widget see calling get(x, y).symbol("x")
), as well as a call to methods in the buffer that call these methods e.g. buf.set_style(area, Color::Blue)
.
--- a/tests/terminal.rs
+++ b/tests/terminal.rs
@@ -38,7 +38,7 @@ fn terminal_draw_returns_the_completed_frame() -> Result<(), Box<dyn Error>> {
let paragraph = Paragraph::new("Test");
f.render_widget(paragraph, f.size());
})?;
- assert_eq!(frame.buffer.get(0, 0).symbol(), "T");
+ assert_eq!(frame.buffer.get(30_000, 0).symbol(), "T");
assert_eq!(frame.area, Rect::new(0, 0, 10, 10));
Note that the test output panicked at the diff line and not at the assertion inside the
--- a/src/widgets/list.rs
+++ b/src/widgets/list.rs
@@ -992,7 +992,7 @@ impl StatefulWidgetRef for List<'_> {
};
if selection_spacing {
buf.set_stringn(
- x,
+ x + 30_000,
y + j as u16,
symbol,
list_area.width as usize,
The panic happened inside the |
Added / adjusted tests. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1046 +/- ##
=======================================
- Coverage 89.4% 89.4% -0.1%
=======================================
Files 61 61
Lines 15430 15425 -5
=======================================
- Hits 13799 13794 -5
Misses 1631 1631 ☔ View full report in Codecov by Sentry. |
These tests are unrelated to this PR? This PR is about track_caller to simplify finding issues with x / y supplied. |
Good catch - I didn't think of that. I'll remove and merge this without the added tests. |
4116b9a
to
87c239e
Compare
The caller put in the wrong x/y -> the caller is the cause.
The caller put in the wrong x/y -> the caller is the cause.
In the future get and get_mut should return Option but thats a bigger change.