@@ -41,6 +41,7 @@ export type PromptFieldProps = {
4141 on_at_sign_click : ( ) => void
4242 on_hash_sign_click : ( ) => void
4343 on_curly_braces_click : ( ) => void
44+ send_with_shift_enter ?: boolean
4445 caret_position_to_set ?: number
4546 on_caret_position_set ?: ( ) => void
4647 focus_key ?: number
@@ -58,6 +59,7 @@ export type PromptFieldProps = {
5859export const PromptField : React . FC < PromptFieldProps > = ( props ) => {
5960 const input_ref = useRef < HTMLDivElement > ( null )
6061 const [ caret_position , set_caret_position ] = useState ( 0 )
62+ const [ should_show_ghost_text , set_should_show_ghost_text ] = useState ( false )
6163 const [ show_at_sign_tooltip , set_show_at_sign_tooltip ] = useState ( false )
6264 const [ show_submit_tooltip , set_show_submit_tooltip ] = useState ( false )
6365 const [ is_text_selecting , set_is_text_selecting ] = useState ( false )
@@ -80,7 +82,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
8082 const { ghost_text, handle_accept_ghost_text } = use_ghost_text ( {
8183 value : props . value ,
8284 input_ref,
83- is_focused,
85+ is_focused : is_focused && should_show_ghost_text ,
8486 currently_open_file_text : props . currently_open_file_text ,
8587 caret_position
8688 } )
@@ -105,6 +107,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
105107
106108 const handle_mouse_down = useCallback (
107109 ( e : React . MouseEvent < HTMLDivElement > ) => {
110+ set_should_show_ghost_text ( false )
108111 mouse_down_pos_ref . current = { x : e . clientX , y : e . clientY }
109112
110113 const handle_mouse_move = ( move_e : MouseEvent ) => {
@@ -310,6 +313,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
310313 < button
311314 className = { cn ( styles [ 'clear-button' ] , 'codicon' , 'codicon-close' ) }
312315 onClick = { ( ) => {
316+ set_should_show_ghost_text ( false )
313317 handle_clear ( )
314318 input_ref . current ?. focus ( )
315319 } }
@@ -320,8 +324,14 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
320324 ref = { input_ref }
321325 contentEditable = { true }
322326 suppressContentEditableWarning = { true }
323- onInput = { handle_input_change }
324- onKeyDown = { handle_key_down }
327+ onInput = { ( e ) => {
328+ set_should_show_ghost_text ( true )
329+ handle_input_change ( e )
330+ } }
331+ onKeyDown = { ( e ) => {
332+ set_should_show_ghost_text ( true )
333+ handle_key_down ( e )
334+ } }
325335 onCopy = { handle_copy }
326336 onPaste = { handle_paste }
327337 onClick = { handle_input_click }
0 commit comments