@@ -70,7 +70,12 @@ export function Autocomplete(props: {
7070 const extmarkStart = store . index
7171 const extmarkEnd = extmarkStart + virtualText . length
7272
73- const styleId = part . type === "file" ? props . fileStyleId : part . type === "agent" ? props . agentStyleId : undefined
73+ const styleId =
74+ part . type === "file"
75+ ? props . fileStyleId
76+ : part . type === "agent"
77+ ? props . agentStyleId
78+ : undefined
7479
7580 const extmarkId = input . extmarks . create ( {
7681 start : extmarkStart ,
@@ -169,7 +174,9 @@ export function Autocomplete(props: {
169174 )
170175 } )
171176
172- const session = createMemo ( ( ) => ( props . sessionID ? sync . session . get ( props . sessionID ) : undefined ) )
177+ const session = createMemo ( ( ) =>
178+ props . sessionID ? sync . session . get ( props . sessionID ) : undefined ,
179+ )
173180 const commands = createMemo ( ( ) : AutocompleteOption [ ] => {
174181 const results : AutocompleteOption [ ] = [ ]
175182 const s = session ( )
@@ -248,9 +255,9 @@ export function Autocomplete(props: {
248255 } )
249256
250257 const options = createMemo ( ( ) => {
251- const mixed : AutocompleteOption [ ] = ( store . visible === "@" ? [ ... agents ( ) , ... files ( ) ] : [ ... commands ( ) ] ) . filter (
252- ( x ) => x . disabled !== true ,
253- )
258+ const mixed : AutocompleteOption [ ] = (
259+ store . visible === "@" ? [ ... agents ( ) , ... files ( ) ] : [ ... commands ( ) ]
260+ ) . filter ( ( x ) => x . disabled !== true )
254261 if ( ! filter ( ) ) return mixed . slice ( 0 , 10 )
255262 const result = fuzzysort . go ( filter ( ) ! , mixed , {
256263 keys : [ "display" , "description" ] ,
@@ -320,8 +327,13 @@ export function Autocomplete(props: {
320327 if ( ! store . visible ) {
321328 if ( e . name === "@" ) {
322329 const cursorOffset = props . input ( ) . visualCursor . offset
323- const charBeforeCursor = cursorOffset === 0 ? undefined : props . value . at ( cursorOffset - 1 )
324- if ( charBeforeCursor === " " || charBeforeCursor === undefined ) {
330+ const charBeforeCursor =
331+ cursorOffset === 0 ? undefined : props . value . at ( cursorOffset - 1 )
332+ if (
333+ charBeforeCursor === " " ||
334+ charBeforeCursor === "\n" ||
335+ charBeforeCursor === undefined
336+ ) {
325337 show ( "@" )
326338 }
327339 }
@@ -365,9 +377,14 @@ export function Autocomplete(props: {
365377 backgroundColor = { index ( ) === store . selected ? Theme . primary : undefined }
366378 flexDirection = "row"
367379 >
368- < text fg = { index ( ) === store . selected ? Theme . background : Theme . text } > { option . display } </ text >
380+ < text fg = { index ( ) === store . selected ? Theme . background : Theme . text } >
381+ { option . display }
382+ </ text >
369383 < Show when = { option . description } >
370- < text fg = { index ( ) === store . selected ? Theme . background : Theme . textMuted } > { option . description } </ text >
384+ < text fg = { index ( ) === store . selected ? Theme . background : Theme . textMuted } >
385+ { " " }
386+ { option . description }
387+ </ text >
371388 </ Show >
372389 </ box >
373390 ) }
0 commit comments