aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2024-11-11 17:13:28 +0100
committerHannes Domani <ssbssa@yahoo.de>2024-11-11 17:13:45 +0100
commit427cc3b541e65b24b78bddb5c0672e871947132c (patch)
tree3429f4ccd0de18b5cb7c9bc0946b32519b78e446 /gdb/tui
parentdf0445b370f66b781a0fcb88270d71df154e4985 (diff)
downloadgdb-427cc3b541e65b24b78bddb5c0672e871947132c.zip
gdb-427cc3b541e65b24b78bddb5c0672e871947132c.tar.gz
gdb-427cc3b541e65b24b78bddb5c0672e871947132c.tar.bz2
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 <tom@tromey.com>
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-source.c4
1 files changed, 2 insertions, 2 deletions
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<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);