@@ -17,7 +17,7 @@ import { useTerminalDimensions } from "@opentui/solid"
1717import { Locale } from "@/util/locale"
1818import type { PromptInfo } from "./history"
1919import { useFrecency } from "./frecency"
20- import { useBindings } from "../../keymap"
20+ import { useBindings , useOpencodeModeStack } from "../../keymap"
2121
2222function removeLineRange ( input : string ) {
2323 const hashIndex = input . lastIndexOf ( "#" )
@@ -83,6 +83,7 @@ export function Autocomplete(props: {
8383 const sdk = useSDK ( )
8484 const sync = useSync ( )
8585 const command = useCommandPalette ( )
86+ const modeStack = useOpencodeModeStack ( )
8687 const { theme } = useTheme ( )
8788 const dimensions = useTerminalDimensions ( )
8889 const frecency = useFrecency ( )
@@ -99,6 +100,12 @@ export function Autocomplete(props: {
99100
100101 const [ positionTick , setPositionTick ] = createSignal ( 0 )
101102
103+ createEffect ( ( ) => {
104+ if ( ! store . visible ) return
105+ const popMode = modeStack . push ( "autocomplete" )
106+ onCleanup ( popMode )
107+ } )
108+
102109 createEffect ( ( ) => {
103110 if ( store . visible ) {
104111 let lastPos = { x : 0 , y : 0 , width : 0 }
@@ -284,7 +291,6 @@ export function Autocomplete(props: {
284291 const { filename, part } = createFilePart ( item , lineRange )
285292 const index = store . visible === "@" ? store . index : props . input ( ) . cursorOffset
286293
287- command . suspend ( false )
288294 setStore ( "visible" , false )
289295 setStore ( "index" , index )
290296 insertPart ( filename , part )
@@ -569,7 +575,6 @@ export function Autocomplete(props: {
569575 } ) )
570576
571577 function show ( mode : "@" | "/" ) {
572- command . suspend ( true )
573578 setStore ( {
574579 visible : mode ,
575580 index : props . input ( ) . cursorOffset ,
@@ -586,7 +591,6 @@ export function Autocomplete(props: {
586591 draft . input = props . input ( ) . plainText
587592 } )
588593 }
589- command . suspend ( false )
590594 setStore ( "visible" , false )
591595 }
592596
0 commit comments