Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines gets eaten on right margin on window resize if preceeded by an escape code #978

Closed
kar1 opened this issue Jul 24, 2021 · 3 comments
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.

Comments

@kar1
Copy link
Contributor

kar1 commented Jul 24, 2021

Describe the bug

This issue is a corner case on issue #971 - text wrap on resize. I was unsure if I should necromance the old closed issue.

If I cat a file to the terminal containing lines equal to the term column width, and then grow the terminal window, the lines equal to the former width will be concatenated with the next line.

The #971 bug still persist if the glyphs are enclosed in special escape codes like:
The #971 bug still persist if there is a escape code before the newline. This often happens with the folowing escape sequences:

DEC Special Graphics character set
␛(0 - Start DEC special graphics set
␛(B - Start ASCII, i.e. end DEC special graphics

DEC CSI DECTCEM
␛[?25l - Hides the cursor
␛[?25h - Shows the cursor

DEC Reset
␛0m - Resets cell attributes

DEC Special Graphics character set is often used to draw tables and boxes.
DEC CSI DECTCEM is often used to enclose ansi-art.

There may be other cases like these, but these are the ones that hit me. Let me know if I should test for more cases.

Environment (please complete the following information):

  • OS: Linux X11
  • Version: wezterm 20210722-094608-dcbbda77
  • The active keyboard layout name: DA

To Reproduce

  1. Make a file containing the escape codes:
echo -e "\e(0qqqq\e(B\nSS" > test-rsmacs.txt
echo -e "\e[?25l====\e[?25h\nSS" > test-dectcem.txt
  1. Resize the terminal window to 4 columns and cat the files
cat test-rmacs.txt
cat test-dectcem.txt
  1. Resize the terminal window to >6 columns and observe the lines "────SS" and "====SS".

Test cases

#[test]
fn test_resize_wrap_SGC_issue_978() {
    const LINES: usize = 4;
    let mut term = TestTerm::new(LINES, 4, 0);
    term.print("\u{1b}(0qqqq\u{1b}(B\nSS\n");
    assert_visible_contents(&term, file!(), line!(), &["────", "SS", "", ""]);
    term.resize(LINES, 6, 0, 0);
    assert_visible_contents(&term, file!(), line!(), &["────", "SS", "", ""]);
}

#[test]
fn test_resize_wrap_DECTCM_issue_978() {
    const LINES: usize = 4;
    let mut term = TestTerm::new(LINES, 4, 0);
    term.print("\u{1b}[?25l====\u{1b}[?25h\nSS\n");
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
    term.resize(LINES, 6, 0, 0);
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
}

#[test]
fn test_resize_wrap_escape_code_issue_978() {
    const LINES: usize = 4;
    let mut term = TestTerm::new(LINES, 4, 0);
    term.print("====\u{1b}0m\nSS\n");
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
    term.resize(LINES, 6, 0, 0);
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
}

Configuration

Default config

Expected behavior

Newlines on margin right edge be preserved on terminal resize even when they are enclosed in special escape codes like hide cursor (DECTCEM) and box drawing mode (DEC Special Graphics character set: smacs, rmacs)
Newlines on margin right edge be preserved on terminal resize even when there is an escape code before the newline.

@kar1 kar1 added the bug Something isn't working label Jul 24, 2021
@kar1
Copy link
Contributor Author

kar1 commented Jul 24, 2021

It seems to be an issue if the there is an escape sequence before the newline

#[test]
fn test_resize_wrap_escape_code_issue_978() {
    const LINES: usize = 4;
    let mut term = TestTerm::new(LINES, 4, 0);
    term.print("====\u{1b}0m\nSS\n");
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
    term.resize(LINES, 6, 0, 0);
    assert_visible_contents(&term, file!(), line!(), &["====", "SS", "", ""]);
}

I think my original report was incorrect. It's not when the text is enclosed in special escape codes, but if there is an escape code before the newline.

I have edited the wording on the issue above.

@kar1 kar1 changed the title Newlines gets eaten on right margin on window resize when enclosed in special escape codes Newlines gets eaten on right margin on window resize if preceeded by an escape code Jul 24, 2021
wez added a commit that referenced this issue Jul 25, 2021
This time we set the wrapped attribute when we implicitly emit
a newline and the wrap_next flag is set.

refs: #978
refs: #971
@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Jul 26, 2021
@kar1
Copy link
Contributor Author

kar1 commented Jul 27, 2021

This fixes it. Thank you for your hard work.

@kar1 kar1 closed this as completed Jul 27, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.
Projects
None yet
Development

No branches or pull requests

2 participants