From a57baffa91e173098e7ad541dc2d56510a689a3e Mon Sep 17 00:00:00 2001
From: Patrick Jackson <patrick@jackson.dev>
Date: Fri, 27 Oct 2023 01:45:36 -0600
Subject: [PATCH] fix(fish): improve output for `enter_accept` (#1341)

Fixes 2 issues with the fish shell prompt when using `enter_accept`
1. Runs pre/post exec so the command is added to the atuin history.
2. Adds padding so that the repainting of the shell prompt doesn't overwrite the output.

This adds 2 lines of padding to account for prompts up to 2 lines tall, larger prompts will still cause repainting problems and smaller prompts will be getting an extra line.
---
 atuin/src/shell/atuin.fish | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/atuin/src/shell/atuin.fish b/atuin/src/shell/atuin.fish
index 061ea8d..9f02579 100644
--- a/atuin/src/shell/atuin.fish
+++ b/atuin/src/shell/atuin.fish
@@ -24,7 +24,13 @@ function _atuin_search
         if string match -qg '__atuin_accept__:*' "$h"
           set hist (string match -r '__atuin_accept__:(.*|\s*)' "$h"  | awk 'NR == 2')
           echo $hist
+          # Need to run the pre/post exec functions manually
+          _atuin_preexec $hist
           eval $hist
+          _atuin_postexec
+          # Allow space for repainting the prompt, this will work for prompts up to 2 lines
+          echo
+          echo
         else
           commandline -r "$h"
         end