diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6a3f478a7..8a1e02794 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ fish ?.?.? (released ???) This release fixes the following problems identified in fish 4.3.0: - The sample prompts and themes are correctly installed (:issue:`12241`). +- Last line of command output could be hidden when missing newline (:issue:`12246`). fish 4.3.2 (released December 30, 2025) ======================================= diff --git a/src/common.rs b/src/common.rs index 5eb165044..eb033608a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1031,10 +1031,6 @@ pub fn get_omitted_newline_str() -> &'static str { static OMITTED_NEWLINE_STR: AtomicRef = AtomicRef::new(&""); -pub fn get_omitted_newline_width() -> usize { - OMITTED_NEWLINE_STR.load().len() -} - static OBFUSCATION_READ_CHAR: AtomicU32 = AtomicU32::new(0); pub fn get_obfuscation_read_char() -> char { diff --git a/src/screen.rs b/src/screen.rs index c9cb229fa..23a27a3fe 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -22,8 +22,8 @@ use libc::{ONLCR, STDERR_FILENO, STDOUT_FILENO}; use crate::common::{ - get_ellipsis_char, get_omitted_newline_str, get_omitted_newline_width, - has_working_tty_timestamps, shell_modes, wcs2bytes, write_loop, + get_ellipsis_char, get_omitted_newline_str, has_working_tty_timestamps, shell_modes, wcs2bytes, + write_loop, }; use crate::env::Environment; use crate::flog::{flog, flogf}; @@ -687,10 +687,12 @@ fn abandon_line_string(screen_width: Option) -> Vec { let mut abandon_line_string = Vec::with_capacity(screen_width + 32); + let omitted_newline_str = get_omitted_newline_str(); + // Do the PROMPT_SP hack. // Don't need to check for fish_wcwidth errors; this is done when setting up // omitted_newline_char in common.rs. - let non_space_width = get_omitted_newline_width(); + let non_space_width = omitted_newline_str.chars().count(); // We do `>` rather than `>=` because the code below might require one extra space. if screen_width > non_space_width { if use_terminfo() { @@ -732,13 +734,13 @@ fn abandon_line_string(screen_width: Option) -> Vec { abandon_line_string.write_command(EnterDimMode); } - abandon_line_string.extend_from_slice(get_omitted_newline_str().as_bytes()); + abandon_line_string.extend_from_slice(omitted_newline_str.as_bytes()); abandon_line_string.write_command(ExitAttributeMode); abandon_line_string.extend(repeat_n(b' ', screen_width - non_space_width)); } abandon_line_string.push(b'\r'); - abandon_line_string.extend_from_slice(get_omitted_newline_str().as_bytes()); + abandon_line_string.extend_from_slice(omitted_newline_str.as_bytes()); // Now we are certainly on a new line. But we may have dropped the omitted newline char on // it. So append enough spaces to overwrite the omitted newline char, and then clear all the // spaces from the new line. diff --git a/tests/checks/tmux-omitted-newline.fish b/tests/checks/tmux-omitted-newline.fish new file mode 100644 index 000000000..fcf9305c1 --- /dev/null +++ b/tests/checks/tmux-omitted-newline.fish @@ -0,0 +1,10 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux + +isolated-tmux-start +isolated-tmux send-keys "echo -n 12" Enter +tmux-sleep +isolated-tmux capture-pane -p +# CHECK: prompt 0> echo -n 12 +# CHECK: 12{{\u23CE|\^J|\u00b6|}} +# CHECK: prompt 1>