[PR #5368] Don't reflow a line as wrapped if it broke on the last cell #26284

Closed
opened 2026-01-31 09:15:08 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/5368

State: closed
Merged: No


Summary of the Pull Request

If we write a character to the last cell of a row, we'll mark that row as wrapped.

If we linefeed at that point, we'll unmark that row as wrapped. (Linefeeds are important here, we learned in #5291/#5294 that all cursor movements don't actually break a line).

However, in TextBuffer::Reflow, if we increase the width of that row, we'll actually reflow it and the following row as though the first row wrapped. This is due to a iRight < cOldColsTotal that should have been iRight <= cOldColsTotal.

References

  • See #5291/#5294 for where we learned about cursor movements and line wrapping.

PR Checklist

Validation Steps Performed

Tested with the following command in WSL

printf "%*s\\n" "$(tput cols)" "" | tr " " "X"
  • In conhost, this works like a charm
  • This DOESN'T work in the Terminal. Presumably, the last cell getting written like this causes us to print the 'X' line as wrapped, but we never re-render that character as not wrapped when the line breaks. This seems timing related. I've got a test ready, but I want to make sure the test gets all possible cases here, including WriteCharsLegacy ones

I'm drafting this to get feedback on the < to <= fix so far. I'll work on the conpty fix in the meantime

**Original Pull Request:** https://github.com/microsoft/terminal/pull/5368 **State:** closed **Merged:** No --- ## Summary of the Pull Request If we write a character to the last cell of a row, we'll mark that row as wrapped. If we linefeed at that point, we'll unmark that row as wrapped. (Linefeeds are important here, we learned in #5291/#5294 that all cursor movements don't actually break a line). However, in `TextBuffer::Reflow`, if we increase the width of that row, we'll actually reflow it and the following row as though the first row wrapped. This is due to a `iRight < cOldColsTotal` that should have been `iRight <= cOldColsTotal`. ## References * See #5291/#5294 for where we learned about cursor movements and line wrapping. ## PR Checklist * [x] Closes #3088 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed Tested with the following command in WSL ```sh printf "%*s\\n" "$(tput cols)" "" | tr " " "X" ``` * [x] In conhost, this works like a charm * [ ] This **DOESN'T** work in the Terminal. Presumably, the last cell getting written like this causes us to print the 'X' line as wrapped, but we never re-render that character as _not_ wrapped when the line breaks. This seems timing related. I've got a test ready, but I want to make sure the test gets all possible cases here, _including_ `WriteCharsLegacy` ones I'm drafting this to get feedback on the `<` to `<=` fix so far. I'll work on the conpty fix in the meantime
claunia added the pull-request label 2026-01-31 09:15:08 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26284