mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
parent
4e2ce0af4e
commit
534646f9d3
4 changed files with 20 additions and 2 deletions
|
@ -224,6 +224,7 @@ static int read_interactive(parser_t &parser, wcstring &buff, int nchars, bool s
|
||||||
|
|
||||||
conf.left_prompt_cmd = prompt;
|
conf.left_prompt_cmd = prompt;
|
||||||
conf.right_prompt_cmd = right_prompt;
|
conf.right_prompt_cmd = right_prompt;
|
||||||
|
conf.event = L"fish_read";
|
||||||
|
|
||||||
conf.in = in;
|
conf.in = in;
|
||||||
|
|
||||||
|
@ -233,7 +234,6 @@ static int read_interactive(parser_t &parser, wcstring &buff, int nchars, bool s
|
||||||
commandline_set_buffer(commandline, std::wcslen(commandline));
|
commandline_set_buffer(commandline, std::wcslen(commandline));
|
||||||
scoped_push<bool> interactive{&parser.libdata().is_interactive, true};
|
scoped_push<bool> interactive{&parser.libdata().is_interactive, true};
|
||||||
|
|
||||||
event_fire_generic(parser, L"fish_read");
|
|
||||||
auto mline = reader_readline(nchars);
|
auto mline = reader_readline(nchars);
|
||||||
interactive.restore();
|
interactive.restore();
|
||||||
if (mline) {
|
if (mline) {
|
||||||
|
|
|
@ -2799,6 +2799,7 @@ static int read_i(parser_t &parser) {
|
||||||
conf.syntax_check_ok = true;
|
conf.syntax_check_ok = true;
|
||||||
conf.autosuggest_ok = check_autosuggestion_enabled(parser.vars());
|
conf.autosuggest_ok = check_autosuggestion_enabled(parser.vars());
|
||||||
conf.expand_abbrev_ok = true;
|
conf.expand_abbrev_ok = true;
|
||||||
|
conf.event = L"fish_prompt";
|
||||||
|
|
||||||
if (parser.is_breakpoint() && function_exists(DEBUG_PROMPT_FUNCTION_NAME, parser)) {
|
if (parser.is_breakpoint() && function_exists(DEBUG_PROMPT_FUNCTION_NAME, parser)) {
|
||||||
conf.left_prompt_cmd = DEBUG_PROMPT_FUNCTION_NAME;
|
conf.left_prompt_cmd = DEBUG_PROMPT_FUNCTION_NAME;
|
||||||
|
@ -4009,7 +4010,9 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
||||||
}
|
}
|
||||||
first_prompt = false;
|
first_prompt = false;
|
||||||
|
|
||||||
event_fire_generic(parser(), L"fish_prompt");
|
if (!conf.event.empty()) {
|
||||||
|
event_fire_generic(parser(), conf.event.c_str());
|
||||||
|
}
|
||||||
exec_prompt();
|
exec_prompt();
|
||||||
|
|
||||||
/// A helper that kicks off syntax highlighting, autosuggestion computing, and repaints.
|
/// A helper that kicks off syntax highlighting, autosuggestion computing, and repaints.
|
||||||
|
|
|
@ -196,6 +196,9 @@ struct reader_config_t {
|
||||||
/// Right prompt command, typically fish_right_prompt.
|
/// Right prompt command, typically fish_right_prompt.
|
||||||
wcstring right_prompt_cmd{};
|
wcstring right_prompt_cmd{};
|
||||||
|
|
||||||
|
/// Name of the event to trigger once we're set up.
|
||||||
|
wcstring event{};
|
||||||
|
|
||||||
/// Whether tab completion is OK.
|
/// Whether tab completion is OK.
|
||||||
bool complete_ok{false};
|
bool complete_ok{false};
|
||||||
|
|
||||||
|
|
|
@ -144,3 +144,15 @@ expect_read_prompt()
|
||||||
send("jkl\n")
|
send("jkl\n")
|
||||||
expect_str("ghi then jkl\r\n")
|
expect_str("ghi then jkl\r\n")
|
||||||
expect_prompt()
|
expect_prompt()
|
||||||
|
|
||||||
|
# Long line so we don't have to count prompts
|
||||||
|
sendline("""set -g fish_prompt_fired 0; function dontfire --on-event fish_prompt; set -g fish_prompt_fired (math $fish_prompt_fired + 1); end; function dofire --on-event fish_read; set -g fish_read_fired 1; end""")
|
||||||
|
|
||||||
|
expect_prompt()
|
||||||
|
sendline("read foo")
|
||||||
|
expect_read_prompt()
|
||||||
|
sendline("text")
|
||||||
|
expect_prompt()
|
||||||
|
# Once for right after setting the listener, another for after the read.
|
||||||
|
print_var_contents("fish_prompt_fired", "2")
|
||||||
|
print_var_contents("fish_read_fired", "1")
|
||||||
|
|
Loading…
Reference in a new issue