@@ -153,7 +153,12 @@ function isResolvedToResolvedState(isResolved: boolean) {
153153export const COMMENT_EXPAND_STATE_SETTING = 'commentExpandState' ;
154154export const COMMENT_EXPAND_STATE_COLLAPSE_VALUE = 'collapseAll' ;
155155export const COMMENT_EXPAND_STATE_EXPAND_VALUE = 'expandUnresolved' ;
156- export function getCommentCollapsibleState ( thread : IReviewThread , expand ?: boolean , currentUser ?: string ) {
156+ export function getCommentCollapsibleState ( thread : IReviewThread , expand ?: boolean , currentUser ?: string , isJustCreated ?: boolean ) {
157+ // If the comment was just created, always expand it so the user can review what they wrote
158+ if ( isJustCreated ) {
159+ return vscode . CommentThreadCollapsibleState . Expanded ;
160+ }
161+
157162 const isFromCurrent = ( currentUser && ( thread . comments [ thread . comments . length - 1 ] . user ?. login === currentUser ) ) ;
158163 const isJustSuggestion = thread . comments . length === 1 && thread . comments [ 0 ] . body . startsWith ( '```suggestion' ) && thread . comments [ 0 ] . body . endsWith ( '```' ) ;
159164 if ( thread . isResolved || ( ! thread . isOutdated && isFromCurrent && ! isJustSuggestion ) ) {
@@ -168,7 +173,7 @@ export function getCommentCollapsibleState(thread: IReviewThread, expand?: boole
168173}
169174
170175
171- export function updateThreadWithRange ( context : vscode . ExtensionContext , vscodeThread : GHPRCommentThread , reviewThread : IReviewThread , githubRepositories ?: GitHubRepository [ ] , expand ?: boolean ) {
176+ export function updateThreadWithRange ( context : vscode . ExtensionContext , vscodeThread : GHPRCommentThread , reviewThread : IReviewThread , githubRepositories ?: GitHubRepository [ ] , expand ?: boolean , isJustCreated ?: boolean ) {
172177 if ( ! vscodeThread . range ) {
173178 return ;
174179 }
@@ -177,13 +182,13 @@ export function updateThreadWithRange(context: vscode.ExtensionContext, vscodeTh
177182 if ( editor . document . uri . toString ( ) === vscodeThread . uri . toString ( ) ) {
178183 const endLine = editor . document . lineAt ( vscodeThread . range . end . line ) ;
179184 const range = new vscode . Range ( vscodeThread . range . start . line , 0 , vscodeThread . range . end . line , endLine . text . length ) ;
180- updateThread ( context , vscodeThread , reviewThread , githubRepositories , expand , range ) ;
185+ updateThread ( context , vscodeThread , reviewThread , githubRepositories , expand , range , isJustCreated ) ;
181186 break ;
182187 }
183188 }
184189}
185190
186- export function updateThread ( context : vscode . ExtensionContext , vscodeThread : GHPRCommentThread , reviewThread : IReviewThread , githubRepositories ?: GitHubRepository [ ] , expand ?: boolean , range ?: vscode . Range ) {
191+ export function updateThread ( context : vscode . ExtensionContext , vscodeThread : GHPRCommentThread , reviewThread : IReviewThread , githubRepositories ?: GitHubRepository [ ] , expand ?: boolean , range ?: vscode . Range , isJustCreated ?: boolean ) {
187192 if ( reviewThread . viewerCanResolve && ! reviewThread . isResolved ) {
188193 vscodeThread . contextValue = 'canResolve' ;
189194 } else if ( reviewThread . viewerCanUnresolve && reviewThread . isResolved ) {
@@ -202,7 +207,7 @@ export function updateThread(context: vscode.ExtensionContext, vscodeThread: GHP
202207 applicability : newApplicabilityState
203208 } ;
204209 }
205- vscodeThread . collapsibleState = getCommentCollapsibleState ( reviewThread , expand ) ;
210+ vscodeThread . collapsibleState = getCommentCollapsibleState ( reviewThread , expand , undefined , isJustCreated ) ;
206211 if ( range ) {
207212 vscodeThread . range = range ;
208213 }
0 commit comments