Skip to content

Fix ConsoleRender.height returning terminal.width - #726

Open
cristianchiriac wants to merge 1 commit into
magmax:mainfrom
cristianchiriac:fix/console-render-height-uses-width
Open

cristianchiriac wants to merge 1 commit into
magmax:mainfrom
cristianchiriac:fix/console-render-height-uses-width

Conversation

@cristianchiriac

Copy link
Copy Markdown

Fixes #164.

Bug

ConsoleRender.height returns self.terminal.width instead of self.terminal.height:

@property
def height(self):
    return self.terminal.width or 24

So width and height are always identical, which breaks anything that positions output relative to the bottom of the terminal using self.terminal.location(), e.g. render_in_bottombar() — the y-coordinate is computed from self.height, so on a terminal where width and height differ, it writes outside the visible area and the message never shows up.

Fix

One-line fix: read self.terminal.height instead of self.terminal.width.

Test plan

  • Added test_height_uses_terminal_height_not_width, which stubs terminal with distinct width/height values and asserts each property reads the matching attribute.
  • Verified the new test fails against the unmodified code (height returning the width value) and passes with the fix.
  • pytest tests/ --ignore=tests/acceptance (the acceptance tests need pexpect, which isn't available in this environment): 139 passed, 1 skipped.
  • flake8 on the changed files: clean.

…ight

The height property returned self.terminal.width, so height and width
were always identical. This breaks anything that positions output
relative to the bottom of the terminal using self.terminal.location(),
such as render_in_bottombar(), which can end up writing to a row
outside the terminal and never showing the message.

Fixes magmax#164

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConsoleRenderer uses terminal.widht as value for height

1 participant