]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix using Page-Up in TUI source window close to the top
authorHannes Domani <ssbssa@yahoo.de>
Mon, 11 Nov 2024 16:13:28 +0000 (17:13 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Mon, 11 Nov 2024 16:13:45 +0000 (17:13 +0100)
Currently, when you're already less than a page from the top in the TUI
source window, and you press Page-Up, nothing happens, while I would
expect that it then scrolls the source up to the first line.

It's happening because scrolling a full page up would result in a
negative starting line number, which is then checked if it's higher than
the (unsigned) number of available lines, and since this will always be
true, the original starting line number is restored.
Afterwards it would check if the line number is too low, but since the
negative value was already gone, it didn't do much.

Fixed by moving the low line number check before the maximum line number
check.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/tui/tui-source.c

index 503fb00902f20ae7c6ce32b0896891190e8dd393..9a0a04142b23700f95f366e9f0485a42d6946a0f 100644 (file)
@@ -164,12 +164,12 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
        s = cursal.symtab;
 
       int line_no = m_start_line_or_addr.u.line_no + num_to_scroll;
+      if (line_no <= 0)
+       line_no = 1;
       const std::vector<off_t> *offsets;
       if (g_source_cache.get_line_charpos (s, &offsets)
          && line_no > offsets->size ())
        line_no = m_start_line_or_addr.u.line_no;
-      if (line_no <= 0)
-       line_no = 1;
 
       cursal.line = line_no;
       find_line_pc (cursal.symtab, cursal.line, &cursal.pc);