Julien-cpsn / ATAC

A simple API client (postman like) in your terminal
https://atac.julien-cpsn.com/
MIT License
1.86k stars 81 forks source link

'attempt to subtract with overflow' when pressing enter in response view #15

Closed BdN3504 closed 5 months ago

BdN3504 commented 5 months ago

https://github.com/Julien-cpsn/ATAC/blob/main/src/app/ui/param_tabs/headers_tab.rs#L117 throws 'attempt to subtract with overflow' when pressing enter in the response body view, avoid this by using wrapping_sub:

let text_input = Paragraph::new(format!("{:fill$}", header_text, fill = cell_width.wrapping_sub(horizontal_margin) as usize));

Julien-cpsn commented 5 months ago

Thanks for your feedback! Is it solved by https://github.com/Julien-cpsn/ATAC/pull/18 ?

BdN3504 commented 5 months ago

Does not seem to be solved by #18 , still getting

Thread 'main' panicked at src/app/ui/param_tabs/headers_tab.rs:117:41: attempt to subtract with overflow

BdN3504 commented 5 months ago

You also have a typo here, it should be called cell_width instead of cell_with.

https://github.com/Julien-cpsn/ATAC/pull/18/files#diff-f38ad632f6b9a4d059e3dff29ae6525bd3f0808f2c65f8c2a0ac34c5a6ce2982R95

From a UX standpoint it's also questionable why this error is thrown in the first place. I now understand what's happening a bit better, but it's weird that this is possible.

When you cycle views and you are viewing the response tab in full screen, pressing 'tab' should not switch menu items for the request tab in the background, because you don't see it. If the response tab is in full screen, pressing 'tab' should cycle through the menu items in the response tab. The way it is right now, you have to press shift+tab to cycle the response tab items, that's pretty counter-intuitive when that tab is in full screen.

See the attached video, and notice how the menu items on the bottom right change when being in full screen mode, but the tab remains the same: Screencast from 2024-04-16 23-34-32.webm

Julien-cpsn commented 5 months ago

You also have a typo here, it should be called cell_width instead of cell_with.

https://github.com/Julien-cpsn/ATAC/pull/18/files#diff-f38ad632f6b9a4d059e3dff29ae6525bd3f0808f2c65f8c2a0ac34c5a6ce2982R95

Thanks for that one, I'll correct it.

From a UX standpoint it's also questionable why this error is thrown in the first place. I now understand what's happening a bit better, but it's weird that this is possible.

I'll check that

When you cycle views and you are viewing the response tab in full screen, pressing 'tab' should not switch menu items for the request tab in the background, because you don't see it. If the response tab is in full screen, pressing 'tab' should cycle through the menu items in the response tab. The way it is right now, you have to press shift+tab to cycle the response tab items, that's pretty counter-intuitive when that tab is in full screen.

See the attached video, and notice how the menu items on the bottom right change when being in full screen mode, but the tab remains the same: Screencast from 2024-04-16 23-34-32.webm

You are totally right, I did not event think of that. I will also give it a look Thanks for your feedback!