From: Hannes Domani Date: Mon, 11 Nov 2024 16:13:28 +0000 (+0100) Subject: Fix using Page-Up in TUI source window close to the top X-Git-Tag: gdb-16-branchpoint~464 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=427cc3b541e65b24b78bddb5c0672e871947132c;p=thirdparty%2Fbinutils-gdb.git Fix using Page-Up in TUI source window close to the top 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 --- diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 503fb00902f..9a0a04142b2 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -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 *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);