fix: prefer valid position for comment line fallback

This commit is contained in:
2026-04-08 23:37:20 +08:00
parent d00e6bcb2c
commit eb7dd1125d
2 changed files with 69 additions and 1 deletions
+16 -1
View File
@@ -197,12 +197,27 @@ fn to_commit_item(commit: CommitDto) -> CommitItem {
}
fn to_comment_item(comment: ReviewCommentDto) -> CommentItem {
let line = if let Some(value) = comment.line.filter(|value| *value > 0) {
Some(value)
} else if let Some(value) = comment
.position
.filter(|value| *value > 0)
.and_then(|value| i64::try_from(value).ok())
{
Some(value)
} else {
comment
.original_position
.filter(|value| *value > 0)
.and_then(|value| i64::try_from(value).ok())
};
CommentItem {
id: comment.id,
user: comment.user.login,
created_at: comment.created_at,
path: comment.path,
line: comment.line,
line,
body: comment.body,
}
}