diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-18 16:30:34 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-18 16:55:09 +1000 |
commit | e73de332a1efcc8f25e5e0f4f9e0a42d7aabb923 (patch) | |
tree | 62ce6b1996894e666940d7b742b54b335d15cf12 /pkg/gui/patch_building_panel.go | |
parent | b28b2d05bd26519d61730c6ced0ba61916aeb456 (diff) |
refactor line by line panel
Diffstat (limited to 'pkg/gui/patch_building_panel.go')
-rw-r--r-- | pkg/gui/patch_building_panel.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go index b7ff83f3c..5c1d4de5f 100644 --- a/pkg/gui/patch_building_panel.go +++ b/pkg/gui/patch_building_panel.go @@ -17,7 +17,7 @@ func (gui *Gui) getFromAndReverseArgsForDiff(to string) (string, bool) { return from, reverse } -func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *lBlPanelState) error { +func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *LblPanelState) error { if !gui.GitCommand.PatchManager.Active() { return gui.handleEscapePatchBuildingPanel() } @@ -43,7 +43,7 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *lBlPanelSt return err } - empty, err := gui.refreshLineByLinePanel(diff, secondaryDiff, false, selectedLineIdx, state) + empty, err := gui.refreshLineByLinePanel(diff, secondaryDiff, false, selectedLineIdx) if err != nil { return err } @@ -63,14 +63,14 @@ func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error { } func (gui *Gui) handleToggleSelectionForPatch() error { - err := gui.withLBLActiveCheck(func(state *lBlPanelState) error { + err := gui.withLBLActiveCheck(func(state *LblPanelState) error { toggleFunc := gui.GitCommand.PatchManager.AddFileLineRange filename := gui.getSelectedCommitFileName() includedLineIndices, err := gui.GitCommand.PatchManager.GetFileIncLineIndices(filename) if err != nil { return err } - currentLineIsStaged := utils.IncludesInt(includedLineIndices, state.SelectedLineIdx) + currentLineIsStaged := utils.IncludesInt(includedLineIndices, state.GetSelectedLineIdx()) if currentLineIsStaged { toggleFunc = gui.GitCommand.PatchManager.RemoveFileLineRange } @@ -81,7 +81,9 @@ func (gui *Gui) handleToggleSelectionForPatch() error { return nil } - if err := toggleFunc(node.GetPath(), state.FirstLineIdx, state.LastLineIdx); err != nil { + firstLineIdx, lastLineIdx := state.SelectedRange() + + if err := toggleFunc(node.GetPath(), firstLineIdx, lastLineIdx); err != nil { // might actually want to return an error here gui.Log.Error(err) } |