Skip to content

Commit 8d42d77

Browse files
Copilotalexr00
andauthored
Refactor: consolidate GHPRComment type checks for file path and body extraction
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/eee01273-3d0c-403d-8bf7-8fbf1a909169 Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent b9984b6 commit 8d42d77

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/commands.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,10 +1850,15 @@ ${contents}
18501850
const commentThread = isThread ? comment : comment.parent;
18511851
const firstComment = isThread ? comment.comments[0] : comment;
18521852
commentThread.collapsibleState = vscode.CommentThreadCollapsibleState.Collapsed;
1853-
const commentBody = firstComment instanceof GHPRComment ? firstComment.rawComment.body
1854-
: (firstComment.body instanceof vscode.MarkdownString ? firstComment.body.value : firstComment.body);
1855-
1856-
const filePath = firstComment instanceof GHPRComment ? firstComment.rawComment.path : undefined;
1853+
let commentBody: string;
1854+
let filePath: string | undefined;
1855+
if (firstComment instanceof GHPRComment) {
1856+
commentBody = firstComment.rawComment.body;
1857+
filePath = firstComment.rawComment.path;
1858+
} else {
1859+
commentBody = firstComment.body instanceof vscode.MarkdownString ? firstComment.body.value : firstComment.body;
1860+
filePath = undefined;
1861+
}
18571862
const range = commentThread.range;
18581863
let message: string;
18591864
if (filePath && range) {

0 commit comments

Comments
 (0)