mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 10:51:15 -03:00
Temporary hack to restore historical behavior of "read --prompt-str ''"
As mentioned in commit 289057f981 (reset_abandoning_line: actually
clear line on first prompt, 2025-11-11), we want to eventually allow
builtin read with a starting cursor with x>0. Until then, add a hack
to restore historical behavior in the case that users observed.
See #12296
This commit is contained in:
@@ -248,6 +248,7 @@ fn read_interactive(
|
||||
shell: bool,
|
||||
silent: bool,
|
||||
prompt: &wstr,
|
||||
prompt_str_is_empty: bool,
|
||||
right_prompt: &wstr,
|
||||
commandline: &Option<WString>,
|
||||
inputfd: RawFd,
|
||||
@@ -265,6 +266,7 @@ fn read_interactive(
|
||||
expand_abbrev_ok: false,
|
||||
|
||||
exit_on_interrupt: true,
|
||||
read_prompt_str_is_empty: prompt_str_is_empty,
|
||||
in_silent_mode: silent,
|
||||
|
||||
left_prompt_cmd: prompt.to_owned(),
|
||||
@@ -644,6 +646,7 @@ pub fn read(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui
|
||||
opts.shell,
|
||||
opts.silent,
|
||||
opts.prompt.as_ref().unwrap(),
|
||||
opts.prompt_str.as_ref().is_some_and(|ps| ps.is_empty()),
|
||||
&opts.right_prompt,
|
||||
&opts.commandline,
|
||||
streams.stdin_fd(),
|
||||
|
||||
@@ -479,6 +479,8 @@ pub struct ReaderConfig {
|
||||
/// Whether to exit on interrupt (^C).
|
||||
pub exit_on_interrupt: bool,
|
||||
|
||||
pub read_prompt_str_is_empty: bool,
|
||||
|
||||
/// If set, do not show what is typed.
|
||||
pub in_silent_mode: bool,
|
||||
|
||||
@@ -2372,16 +2374,17 @@ fn readline(
|
||||
|
||||
self.history_search.reset();
|
||||
|
||||
// HACK: Don't abandon line for the first prompt, because
|
||||
// if we're started with the terminal it might not have settled,
|
||||
// so the width is quite likely to be in flight.
|
||||
// HACK: Use a simple \r for the first prompt, because if we're started with the terminal
|
||||
// it might not have settled, so the width is quite likely to be in flight.
|
||||
//
|
||||
// This means that `printf %s foo; fish` will overwrite the `foo`,
|
||||
// but that's a smaller problem than having the omitted newline char
|
||||
// appear constantly.
|
||||
let trusted_width = (!self.first_prompt).then_some(termsize_last().width());
|
||||
if !self.first_prompt || !self.conf.read_prompt_str_is_empty {
|
||||
let trusted_width = (!self.first_prompt).then_some(termsize_last().width());
|
||||
self.screen.reset_abandoning_line(trusted_width);
|
||||
}
|
||||
self.first_prompt = false;
|
||||
self.screen.reset_abandoning_line(trusted_width);
|
||||
|
||||
if !self.conf.event.is_empty() {
|
||||
event::fire_generic(self.parser, self.conf.event.to_owned(), vec![]);
|
||||
|
||||
Reference in New Issue
Block a user