Skip to content

Conversation

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Oct 1, 2025

The root cause of the this lis the calc_screen() method of reader.py. When screen, screeninfo, and line_end_offsets are retrieved from the cache, they are passed by direct reference instead of by a copy.

before this patch

2025-10-01.12.31.25.mov

after this patch

2025-10-01.12.57.17.mov

del screeninfo[num_common_lines:]

last_refresh_line_end_offsets = self.last_refresh_cache.line_end_offsets
last_refresh_line_end_offsets = self.last_refresh_cache.line_end_offsets.copy()
Copy link

@kemingy kemingy Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this last_refresh_line_end_offsets has never been used in this function. The bug can be fixed by deleting this one.

The other two screen & screeninfo are synced back to self.last_refresh_cache. But for readability & maintenance, we should copy them here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@kemingy
Copy link

kemingy commented Oct 1, 2025

The failed Windows test (test.test_pyrepl.test_windows_console.WindowsConsoleTests.test_multiline_ctrl_z) is not caused by this PR.

If we add the reader.screeninfo to the assert msg:

- (4, 2)
+ (2, 3) : [(0, [1, 1, 1, 1, 1]), (0, [1, 1, 1, 1, 1]), (0, [1, 2, 1])]

yihong0618 and others added 2 commits October 1, 2025 18:48
Signed-off-by: yihong0618 <[email protected]>
Co-authored-by: Keming <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
@yihong0618
Copy link
Contributor Author

@picnixz friendly ping and also fix #142078

@yihong0618 yihong0618 requested a review from picnixz November 29, 2025 10:24
@TotalyEnglizLitrate
Copy link

TotalyEnglizLitrate commented Nov 29, 2025

Other escape characters being present in sys.ps1 (or indirectly via input) also cause the following issues not seen in the basic REPL

Namely (appended them at the end of >>> for demonstration)
\t - causes prompt to be shown doubly upon very first character input

\b (and/or) \r - causes displayed cursor position to be out-of-sync with true cursor position (the displayed cursor does not account for the backward shift caused by the escape sequences)

  • for >>>\b - cursor is displayed 2 spaces beyond true position (1 because it perceives \b as a single char that exists after >>> and the other due to the cursor being moved 1 space back)
  • for >>>\r - similar problem, actual cursor is displayed 4 spaces later for the same reason

\v - similar issue to \n - additionally causes cursor position discrepancy of a single space

there may be others I didn't catch as well

output.mp4

all of these still occur in 3.13, 3.14, main as well as in this patched version (and none occur when using the basic repl)

will/should these be addressed here or should I create a separate issue?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants