MCPcopy
hub / github.com/rgburke/grv / switchToDiffIfExists

Method switchToDiffIfExists

cmd/grv/diff_view.go:374–398  ·  view source on GitHub ↗
(diffID diffID)

Source from the content-addressed store, hash-verified

372}
373
374func (diffView *DiffView) switchToDiffIfExists(diffID diffID) (exists bool) {
375 diffLines, exists := diffView.diffs[diffID]
376 if exists {
377 if diffLines.diffType != diffView.currentDiffProcessorType() {
378 diffProcessor, diffType := diffView.currentDiffProcessor()
379 lines, err := diffProcessor.processDiff(diffLines.rawLines)
380
381 if err != nil {
382 log.Errorf("Failed to convert diff to format %v: %v", diffType, err)
383 diffLines.diffType = dptGit
384 diffLines.lines = diffLines.rawLines
385 } else {
386 diffLines.diffType = diffType
387 diffLines.lines = lines
388 }
389 }
390
391 diffView.activeDiff = diffID
392 diffView.activeViewPos = diffLines.viewPos
393 diffView.setVariables()
394 diffView.channels.UpdateDisplay()
395 }
396
397 return
398}
399
400// OnFileSelected loads/fetches the diff for the selected file and refreshes the display
401func (diffView *DiffView) OnFileSelected(statusType StatusType, filePath string) {

Callers 2

OnCommitSelectedMethod · 0.95

Calls 5

currentDiffProcessorMethod · 0.95
setVariablesMethod · 0.95
processDiffMethod · 0.65
UpdateDisplayMethod · 0.65

Tested by

no test coverage detected