Skip to content

Conversation

maoyama
Copy link
Owner

@maoyama maoyama commented May 10, 2025

No description provided.

@maoyama maoyama requested a review from Copilot May 10, 2025 00:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issues with staging file and chunk diffs by improving how optional values are handled and updating patch outputs.

  • Changes optional checks from shorthand binding to explicit nil checks in cachedDiff and diff.
  • Updates patch handling to safely unwrap optional values before processing.
  • Explicitly ignores the output of the GitAddPatch process.

Comment on lines +73 to +82
if cachedDiff != nil {
StagedView(
fileDiffs: $cachedExpandableFileDiffs,
onSelectFileDiff: { fileDiff in
let newDiff = cachedDiff.updateFileDiffStage(fileDiff, stage: false)
restorePatch(newDiff)
if let newDiff = self.cachedDiff?.updateFileDiffStage(fileDiff, stage: false) {
restorePatch(newDiff)
}
},
onSelectChunk: { fileDiff, chunk in
let newDiff = cachedDiff.updateChunkStage(chunk, in: fileDiff, stage: false)
restorePatch(newDiff)
if let newDiff = self.cachedDiff?.updateChunkStage(chunk, in: fileDiff, stage: false) {
Copy link
Preview

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using optional binding (e.g., 'if let cached = self.cachedDiff') instead of checking 'cachedDiff != nil' to avoid redundant optional chaining when calling updateFileDiffStage.

Copilot uses AI. Check for mistakes.

Comment on lines +90 to +100
if diff != nil {
UnstagedView(
fileDiffs: $expandableFileDiffs,
untrackedFiles: status?.untrackedFiles ?? [],
onSelectFileDiff: { fileDiff in
let newDiff = diff.updateFileDiffStage(fileDiff, stage: true)
addPatch(newDiff)
if let newDiff = self.diff?.updateFileDiffStage(fileDiff, stage: true) {
addPatch(newDiff)
}
},
onSelectChunk: { fileDiff, chunk in
let newDiff = diff.updateChunkStage(chunk, in: fileDiff, stage: true)
addPatch(newDiff)
if let newDiff = self.diff?.updateChunkStage(chunk, in: fileDiff, stage: true) {
Copy link
Preview

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilize optional binding (e.g., 'if let diffValue = diff') to safely unwrap and reuse the value for updateFileDiffStage, rather than checking for nil separately.

Copilot uses AI. Check for mistakes.

@maoyama maoyama merged commit 75faa6b into main May 10, 2025
4 checks passed
@maoyama maoyama deleted the fix-stage-this-hunk branch May 10, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant