prompt-toolkit / prompt-toolkit/python-prompt-toolkit
renderer.py checks platform for windows, rather than checking if the Output object is Windows output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
While working with contrib/ssh on my Windows10 box, I found a problem with renderer.py
Before calling get_rows_below_cursor_position() in request_absolute_cursor_position() we check is_windows(). This seems incorrect to me, because the platform is not the issue, but the Output is. When creating an SSHD server on Windows, the output is actually a Vt100, but this platform check bogs that up. There are a few other calls to is_windows() in renderer.py but I didn't investigate them.
This is how I'm handling it locally:
--- a/prompt_toolkit/renderer.py 2020-05-29 13:15:17.928292000 -0700
+++ b/prompt_toolkit/renderer.py 2020-05-29 13:21:18.235659400 -0700
@@ -422,7 +422,7 @@
# For Win32, we have an API call to get the number of rows below the
# cursor.
- elif is_windows():
+ elif type(self.output).__name__ in ('Win32Output','Windows10_Output'):
self._min_available_height = self.output.get_rows_below_cursor_position()
# Use CPR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in prompt_toolkit/renderer.py, especially request_absolute_cursor_position() and the call to get_rows_below_cursor_position(). Inspect how the Output object is represented for Win32, Windows10, and Vt100 outputs before reviewing the other is_windows() checks. Done means platform-independent output handling works for the Windows SSHD/Vt100 case without breaking native Windows output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100