[PATCH] Fix: call using_history after initializing history entries

Antoine Busque <[email protected]> Wed, 2 Aug 2017 23:02:00 -0400
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
In its current state, history expansion requiring any sort of string
lookup is not working, always returing "event not found". This is due
to `history_offset` being set improperly by an early call to
`using_history`.

A call to `using_history` needs to follow, not precede, the loop
performing initialization of history entries found in
`history_expand_line`. This allows for `history_offset` to reflect the
now non-zero length of the history, restoring the expected behaviour
of history expansion.

Tested-by: Martin Hertz <[email protected]>
Signed-off-by: Antoine Busque <[email protected]>
---
 src/history.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/history.c b/src/history.c
index d1e9938..1466e89 100644
--- a/src/history.c
+++ b/src/history.c
@@ -314,10 +314,10 @@ history_expand_line (int history_id UNUSED, char *string, char **output)
 
   if (strchr (string, '!')) {
     clear_history ();
-    using_history ();
     list_for_each_entry(item, &histories[history_id].head, node) {
       add_history (item->line);
     }
+    using_history ();
     return history_expand (string, output);
   }
 #endif
-- 
2.13.3