@@ -307,38 +307,6 @@ export const submitInputAtom = atom(null, (get, set, text: string | Buffer) => {
307307// Keyboard Handler System
308308// ============================================================================
309309
310- /**
311- * Helper function to get the completion text (only the missing part to append)
312- */
313- function getCompletionText ( currentInput : string , suggestion : CommandSuggestion | ArgumentSuggestion ) : string {
314- if ( "command" in suggestion ) {
315- // CommandSuggestion - complete the command name
316- const commandName = suggestion . command . name
317- const currentText = currentInput . startsWith ( "/" ) ? currentInput . slice ( 1 ) : currentInput
318-
319- // If the command name starts with what user typed, return only the missing part
320- if ( commandName . toLowerCase ( ) . startsWith ( currentText . toLowerCase ( ) ) ) {
321- return commandName . slice ( currentText . length )
322- }
323-
324- // Otherwise return the full command (shouldn't happen in normal flow)
325- return commandName
326- } else {
327- // ArgumentSuggestion - complete the last argument
328- const parts = currentInput . split ( " " )
329- const lastPart = parts [ parts . length - 1 ] || ""
330- const suggestionValue = suggestion . value
331-
332- // If suggestion starts with what user typed, return only the missing part
333- if ( suggestionValue . toLowerCase ( ) . startsWith ( lastPart . toLowerCase ( ) ) ) {
334- return suggestionValue . slice ( lastPart . length )
335- }
336-
337- // Otherwise return the full value
338- return suggestionValue
339- }
340- }
341-
342310/**
343311 * Helper function to format autocomplete suggestions for display/submission
344312 */
@@ -487,17 +455,10 @@ function handleAutocompleteKeys(get: any, set: any, key: Key): void {
487455 const suggestion = allSuggestions [ selectedIndex ]
488456 const currentText = get ( textBufferStringAtom )
489457
490- // For argument suggestions, replace the entire input with formatted suggestion
491- // For command suggestions, append the completion text
492- if ( "command" in suggestion ) {
493- // CommandSuggestion - append only the missing part
494- const completionText = getCompletionText ( currentText , suggestion )
495- set ( insertTextAtom , completionText )
496- } else {
497- // ArgumentSuggestion - replace entire input to avoid duplication
498- const newText = formatSuggestion ( suggestion , currentText )
499- set ( setTextAtom , newText )
500- }
458+ // Always replace the entire input with formatted suggestion
459+ // This handles both commands and arguments correctly
460+ const newText = formatSuggestion ( suggestion , currentText )
461+ set ( setTextAtom , newText )
501462 }
502463 return
503464
0 commit comments