From 427cc3b541e65b24b78bddb5c0672e871947132c Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Mon, 11 Nov 2024 17:13:28 +0100 Subject: 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 --- gdb/tui/tui-source.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/tui') diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 503fb00..9a0a041 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); -- cgit v1.1