Skip to content

Commit dea54e8

Browse files
authored
Only add @copilot when the text input is clicked into (#7477)
Fixes microsoft/vscode#258675
1 parent f281364 commit dea54e8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

webviews/components/comment.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ export function AddComment({
413413
}
414414
: commentMethods(isIssue);
415415

416-
const commentStartingText = pendingCommentText ?? (isCopilotOnMyBehalf ? '@copilot ' : '');
417-
418416
return (
419417
<form id="comment-form" ref={form as React.MutableRefObject<HTMLFormElement>} className="comment-form main-comment-form" onSubmit={() => submit(textareaRef.current?.value ?? '')}>
420418
<textarea
@@ -423,8 +421,14 @@ export function AddComment({
423421
ref={textareaRef as React.MutableRefObject<HTMLTextAreaElement>}
424422
onInput={({ target }) => updatePR({ pendingCommentText: (target as any).value })}
425423
onKeyDown={onKeyDown}
426-
value={commentStartingText}
424+
value={pendingCommentText}
427425
placeholder="Leave a comment"
426+
onClick={() => {
427+
if (!pendingCommentText && isCopilotOnMyBehalf && !textareaRef.current?.textContent) {
428+
textareaRef.current!.textContent = '@copilot ';
429+
textareaRef.current!.setSelectionRange(9, 9);
430+
}
431+
}}
428432
/>
429433
<div className="form-actions">
430434
{(hasWritePermission || isAuthor) ? (

0 commit comments

Comments
 (0)