diff --git a/docs/changelog.md b/docs/changelog.md index 7940505ef4b..9b05a9c4908 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -35,6 +35,11 @@ As features stabilize some brief notes about them will accumulate here. * Using `RESIZE|MACOS_FORCE_DISABLE_SHADOW` or `RESIZE|MACOS_FORCE_ENABLE_SHADOW` would cause a spooky titlebar to appear. Thanks to @noefroidevaux! #3330 +* ConPTY: logical line wrapping falsely joining long runs of output from classic + windows console subsystem programs. The behavior now is to only mark long lines + as wrapped if the last character on the prior line is alphanumeric or ascii + punctuation. Other characters will cause the logical line to break. + #3278 #3177 ### 20230320-124340-559cb7b0 diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rs index 714383cd95d..cbd39e72a67 100644 --- a/term/src/terminalstate/performer.rs +++ b/term/src/terminalstate/performer.rs @@ -149,9 +149,32 @@ impl<'a> Performer<'a> { // resized. { let y = self.cursor.y; + let is_conpty = self.state.enable_conpty_quirks; + let is_alt = self.state.screen.alt_screen_is_active; let screen = self.screen_mut(); let y = screen.phys_row(y); - screen.line_mut(y).set_last_cell_was_wrapped(true, seqno); + + fn makes_sense_to_wrap(s: &str) -> bool { + let len = s.len(); + match (len, s.chars().next()) { + (1, Some(c)) => { + c.is_alphanumeric() || c.is_ascii_punctuation() + } + _ => true + } + } + + let should_mark_wrapped = !is_alt + && (!is_conpty + || screen + .line_mut(y) + .visible_cells() + .last() + .map(|cell| makes_sense_to_wrap(cell.str())) + .unwrap_or(false)); + if should_mark_wrapped { + screen.line_mut(y).set_last_cell_was_wrapped(true, seqno); + } } self.new_line(true); }