File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
packages/opencode/src/cli/cmd/tui/component/prompt Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,13 @@ export function Autocomplete(props: {
5151 } )
5252
5353 function insertPart ( text : string , part : PromptInfo [ "parts" ] [ number ] ) {
54- const append = "@" + text + " "
5554 const input = props . input ( )
5655 const currentCursorOffset = input . visualCursor . offset
5756
57+ const charAfterCursor = props . value . at ( currentCursorOffset )
58+ const needsSpace = charAfterCursor !== " " && charAfterCursor !== undefined
59+ const append = "@" + text + ( needsSpace ? " " : "" )
60+
5861 input . cursorOffset = store . index
5962 const startCursor = input . logicalCursor
6063 input . cursorOffset = currentCursorOffset
@@ -316,8 +319,9 @@ export function Autocomplete(props: {
316319 }
317320 if ( ! store . visible ) {
318321 if ( e . name === "@" ) {
319- const last = props . value . at ( - 1 )
320- if ( last === " " || last === undefined ) {
322+ const cursorOffset = props . input ( ) . visualCursor . offset
323+ const charBeforeCursor = cursorOffset === 0 ? undefined : props . value . at ( cursorOffset - 1 )
324+ if ( charBeforeCursor === " " || charBeforeCursor === undefined ) {
321325 show ( "@" )
322326 }
323327 }
You can’t perform that action at this time.
0 commit comments