mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-19 14:51:13 -03:00
Fix PROMPT_SP hack regression
Commit fbad0ab50a (reset_abandoning_line: remove redundant
allocations, 2025-11-13) uses byte count of ⏎ (3) instead of char
count (1), thus overestimating the number of spaces this symbol takes.
Fixes #12246
This commit is contained in:
@@ -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)
|
||||
=======================================
|
||||
|
||||
@@ -1031,10 +1031,6 @@ pub fn get_omitted_newline_str() -> &'static str {
|
||||
|
||||
static OMITTED_NEWLINE_STR: AtomicRef<str> = 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 {
|
||||
|
||||
@@ -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<usize>) -> Vec<u8> {
|
||||
|
||||
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<usize>) -> Vec<u8> {
|
||||
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.
|
||||
|
||||
10
tests/checks/tmux-omitted-newline.fish
Normal file
10
tests/checks/tmux-omitted-newline.fish
Normal file
@@ -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>
|
||||
Reference in New Issue
Block a user