aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-04-20 02:04:17 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-04-20 02:04:17 -0700
commitc3ef23b10f4c5bc5de7e685c631e6c5802dc4db0 (patch)
treef103f8940e21b88f520db6a5da48b6dc1f9f6fa9 /reader.cpp
parent722fedc8fd590cb436109a553fb68f02790117f3 (diff)
Support for a "pending item" in history.
Before running a command, we add the command to history, so that if the command causes us to exit it's still captured in history. But that command should not be considered part of history when expanding the history within the command itself. For example, `echo $history[1]` should be the previously run command, not `echo $history[1]` itself. Fixes #2028
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/reader.cpp b/reader.cpp
index e8bd5615..dbf42195 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -2982,6 +2982,11 @@ static int read_i(void)
event_fire_generic(L"fish_preexec", &argv);
reader_run_command(parser, command);
event_fire_generic(L"fish_postexec", &argv);
+ /* Allow any pending history items to be returned in the history array. */
+ if (data->history)
+ {
+ data->history->resolve_pending();
+ }
if (data->end_loop)
{
handle_end_loop();
@@ -3592,7 +3597,7 @@ const wchar_t *reader_readline(int nchars)
const editable_line_t *el = &data->command_line;
if (data->history != NULL && ! el->empty() && el->text.at(0) != L' ')
{
- data->history->add_with_file_detection(el->text);
+ data->history->add_pending_with_file_detection(el->text);
}
finished=1;
update_buff_pos(&data->command_line, data->command_line.size());