From d1bfba1abbd09e4c70220bc9d82f10b6f61c5b28 Mon Sep 17 00:00:00 2001
From: Sandy Tao <sandytao520@icloud.com>
Date: Mon, 4 Aug 2025 11:30:59 -0700
Subject: feat(core): Add trailing space when completing an at completion
 suggestion (#5475)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
---
 packages/cli/src/ui/hooks/useSlashCompletion.tsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'packages/cli/src/ui/hooks/useSlashCompletion.tsx')

diff --git a/packages/cli/src/ui/hooks/useSlashCompletion.tsx b/packages/cli/src/ui/hooks/useSlashCompletion.tsx
index c6821358..3b59bd45 100644
--- a/packages/cli/src/ui/hooks/useSlashCompletion.tsx
+++ b/packages/cli/src/ui/hooks/useSlashCompletion.tsx
@@ -111,7 +111,7 @@ export function useSlashCompletion(
 
   useEffect(() => {
     if (commandIndex === -1 || reverseSearchActive) {
-      resetCompletionState();
+      setTimeout(resetCompletionState, 0);
       return;
     }
 
@@ -631,17 +631,17 @@ export function useSlashCompletion(
         ) {
           suggestionText = ' ' + suggestionText;
         }
-        suggestionText += ' ';
       }
 
+      suggestionText += ' ';
+
       buffer.replaceRangeByOffset(
         logicalPosToOffset(buffer.lines, cursorRow, completionStart.current),
         logicalPosToOffset(buffer.lines, cursorRow, completionEnd.current),
         suggestionText,
       );
-      resetCompletionState();
     },
-    [cursorRow, resetCompletionState, buffer, suggestions, commandIndex],
+    [cursorRow, buffer, suggestions, commandIndex],
   );
 
   return {
-- 
cgit v1.2.3

