cursive icon indicating copy to clipboard operation
cursive copied to clipboard

[BUG] `ScrollView::scroll_to_top` doesn't work with `ScrollStrategy::StickToBottom`

Open MikeCain opened this issue 2 years ago • 1 comments

Describe the bug I tried using scroll_to_top() on a ScrollView which has ScrollStrategy::StickToBottom set, and nothing happened.

To Reproduce

// Attach this to a global keybinding
pub fn debug_dialog(cursive: &mut Cursive) {
    let debug_view =
        FlexiLoggerView::new()
        .no_indent()
        .scrollable()
        .scroll_strategy(ScrollStrategy::StickToBottom)
        .scroll_x(true)
        .scroll_y(true)
        .with_name("debug");
    let dialog = Dialog::around(debug_view)
        .button("Top", |c| {
            c.call_on_name("debug", |view: &mut ScrollView<FlexiLoggerView>| {
                view.scroll_to_top();
            });
        })
        .dismiss_button("Close")
        .full_screen();
    cursive.add_fullscreen_layer(dialog);
}

Expected behavior Despite the set scroll strategy, I expected the ScrollView to scroll to the top, since nothing new was being added to make the view scroll back down agian.

Screenshots N/A

Environment

  • Operating system used: Linux
  • Backend used: ncurses
  • Current locale: en_US.UTF-8
  • Cursive version: From crates.io, v0.17.0

Additional context N/A

MikeCain avatar May 18 '22 00:05 MikeCain

Hi, and thanks for the report!

We may need a more complete example to properly reproduce the issue.

Though note that the scroll strategy is constantly applied (it doesn't wait for the next line to be appended). It is here to react to events like window resize, independently of changing content.

It sounds like you want to temporarily change the scroll strategy (for example to KeepRow), until new content is appended, in which case you'd like to set the strategy back to StickToBottom?

gyscos avatar Jun 07 '22 16:06 gyscos