[3/3,gdb/tui] Revert workaround in tui_source_window::show_line_number

Message ID 20230411082332.25052-3-tdevries@suse.de
State Committed
Headers
Series [1/3,gdb/tui] Add maint set/show tui-left-margin-verbose |

Commit Message

Tom de Vries April 11, 2023, 8:23 a.m. UTC
  The m_digits member of tui_source_window is documented as having semantics:
...
  /* How many digits to use when formatting the line number.  This
     includes the trailing space.  */
...

The commit 1b6d4bb2232 ("Redraw both spaces between line numbers and source
code") started printing two trailing spaces instead:
...
-  xsnprintf (text, sizeof (text), "%*d ", m_digits - 1, lineno);
+  xsnprintf (text, sizeof (text), "%*d  ", m_digits - 1, lineno);
...

Now that PR30325 is fixed, this no longer has any effect.

Fix this by reverting to the original behaviour: print one trailing space
char.

Tested on x86_64-linux.
---
 gdb/tui/tui-source.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Tom Tromey April 12, 2023, 8:44 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Fix this by reverting to the original behaviour: print one trailing space
Tom> char.

Looks good.  Thanks for doing this.

Tom
  

Patch

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index aa3e58407c4..3d08ea8b7cd 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -232,11 +232,9 @@  tui_source_window::show_line_number (int offset) const
 {
   int lineno = m_content[0].line_or_addr.u.line_no + offset;
   char text[20];
-  /* To completely overwrite the previous border when the source window height
-     is increased, both spaces after the line number have to be redrawn.  */
   char space = tui_left_margin_verbose ? '_' : ' ';
   xsnprintf (text, sizeof (text),
-	     tui_left_margin_verbose ? "%0*d%c%c" : "%*d%c%c", m_digits - 1,
-	     lineno, space, space);
+	     tui_left_margin_verbose ? "%0*d%c" : "%*d%c", m_digits - 1,
+	     lineno, space);
   waddstr (handle.get (), text);
 }