Unwanted empty space at end of output

Open
#2,008 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start at the _output_screen_diff function and inspect how each line's character cell is emitted. Reproduce the issue with an empty terminal running IPython, then verify that empty lines no longer add a trailing space while lines with content still render correctly.

Written by the indexing model from the issue text.

Description

In _output_screen_diff we unconditionally draw a character cell (perhaps containing a space) at each line whether or not that line has any actual content. The result is unwanted spaces appearing at the end of output, e.g. if you start ipython in an empty terminal, the bottom-left corner of that terminal will have a space in it.

If we replace

                output_char(new_char)

with

                if new_max_line_len:
                    output_char(new_char)

we don't output the character when we nothing to show and end up with a cleaner terminal for the user.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prompt-toolkit/python-prompt-toolkit

All issues in prompt-toolkit/python-prompt-toolkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.