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

Scrolling position in Lua console is reset constantly #2067

Closed
Arcanister opened this Issue Oct 2, 2017 · 8 comments

Comments

Projects
None yet
6 participants
@Arcanister
Contributor

Arcanister commented Oct 2, 2017

GNU/Linux, X11, Wesnoth master.

Steps to reproduce:

  1. Start a scenario in debug mode ( e.g. start as wesnoth -dt )
  2. Press [~] key to invoke Lua console
  3. Enter some commands, so window content becomes long enough, for example, a, b, abc, abcd

Actual result:
After enough commands are entered, pressing Enter makes scrolling position jump on top of console text output.

Expected result:
Scroll position should show result of last entered command.

Seems to be unrelated to GNU history support, since reproduces both on builds with and without it.

@sevu

This comment has been minimized.

Show comment
Hide comment
@sevu

sevu Oct 2, 2017

Member

Can confirm this.
It happens (only) with long commands, so that the line with the error message has a line break.

Member

sevu commented Oct 2, 2017

Can confirm this.
It happens (only) with long commands, so that the line with the error message has a line break.

@gfgtdf

This comment has been minimized.

Show comment
Hide comment
@gfgtdf

gfgtdf Oct 2, 2017

Contributor

from looking at the code it seems like it shoudl scroll to the bottom when a new input is executed see this line https://github.com/wesnoth/wesnoth/blob/1.13.9/src/gui/dialogs/lua_interpreter.cpp#L103 which shoudl do that. No idea why it doesn't work.

Contributor

gfgtdf commented Oct 2, 2017

from looking at the code it seems like it shoudl scroll to the bottom when a new input is executed see this line https://github.com/wesnoth/wesnoth/blob/1.13.9/src/gui/dialogs/lua_interpreter.cpp#L103 which shoudl do that. No idea why it doesn't work.

@gfgtdf gfgtdf added Bug UI labels Oct 2, 2017

@Arcanister

This comment has been minimized.

Show comment
Hide comment
@Arcanister

Arcanister Oct 2, 2017

Contributor

Additional testing suggests that indeed problem is triggered when, a printed line doesn't fit in horizontal space, which happens when it's an error message or long string echoed verbatim or something like that.

src/gui/widgets/scrollbar.cpp
@@ -113,6 +114,7 @@ void scrollbar_base::scroll(const scroll_mode scroll)
         *
         * -- vultraz, 2017-09-13
         */
+       std::cerr << "SCROLL: " << item_count_ << std::endl;
        fire(event::NOTIFY_MODIFIED, *this, nullptr);
 }

Adding debug print here indicates that item_count_ is same whenever scroll is done by manually scrolling to end, while console window behaves like expected, but it starts to differ once a sufficiently long line is printed by multiplies of 24. For example when line is printed and view jumps to top, I see SCROLL: 1254 and when I manually scroll to end, I get lines of SCROLL: 1302

Contributor

Arcanister commented Oct 2, 2017

Additional testing suggests that indeed problem is triggered when, a printed line doesn't fit in horizontal space, which happens when it's an error message or long string echoed verbatim or something like that.

src/gui/widgets/scrollbar.cpp
@@ -113,6 +114,7 @@ void scrollbar_base::scroll(const scroll_mode scroll)
         *
         * -- vultraz, 2017-09-13
         */
+       std::cerr << "SCROLL: " << item_count_ << std::endl;
        fire(event::NOTIFY_MODIFIED, *this, nullptr);
 }

Adding debug print here indicates that item_count_ is same whenever scroll is done by manually scrolling to end, while console window behaves like expected, but it starts to differ once a sufficiently long line is printed by multiplies of 24. For example when line is printed and view jumps to top, I see SCROLL: 1254 and when I manually scroll to end, I get lines of SCROLL: 1302

@Vultraz

This comment has been minimized.

Show comment
Hide comment
@Vultraz

Vultraz Oct 3, 2017

Member

Known issue. Something triggers a relayout in the scroll label.

Member

Vultraz commented Oct 3, 2017

Known issue. Something triggers a relayout in the scroll label.

@CelticMinstrel

This comment has been minimized.

Show comment
Hide comment
@CelticMinstrel

CelticMinstrel Oct 7, 2017

Member

This is an issue with long text fields in general, not just the Lua console (you can also trigger it in lobby chat if I recall correctly).

I wonder if we should somehow use a listbox for these things instead? So each line is basically an independent element?

Member

CelticMinstrel commented Oct 7, 2017

This is an issue with long text fields in general, not just the Lua console (you can also trigger it in lobby chat if I recall correctly).

I wonder if we should somehow use a listbox for these things instead? So each line is basically an independent element?

@Arcanister

This comment has been minimized.

Show comment
Hide comment
@Arcanister

Arcanister Oct 7, 2017

Contributor

Is it hard to fix line counting, taking line wrapping into account and invalidating it on window side change?

Contributor

Arcanister commented Oct 7, 2017

Is it hard to fix line counting, taking line wrapping into account and invalidating it on window side change?

@jyrkive jyrkive closed this in d00ed24 Dec 4, 2017

@CelticMinstrel

This comment has been minimized.

Show comment
Hide comment
@CelticMinstrel

CelticMinstrel Dec 5, 2017

Member

I think accounting for line wrapping is (was?) the hard part.

Member

CelticMinstrel commented Dec 5, 2017

I think accounting for line wrapping is (was?) the hard part.

@GregoryLundberg

This comment has been minimized.

Show comment
Hide comment
@GregoryLundberg

GregoryLundberg Dec 5, 2017

Contributor

Best advice: when you're about to press Enter on a Lua command, close your eyes for a second. That way you won't be annoyed at the scroll-top-scroll-bottom flicker.

Contributor

GregoryLundberg commented Dec 5, 2017

Best advice: when you're about to press Enter on a Lua command, close your eyes for a second. That way you won't be annoyed at the scroll-top-scroll-bottom flicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment