summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-25 13:08:45 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-25 21:37:16 +1100
commitdd1bf629b87db297a6336511a4e1ba39ba7afbc8 (patch)
treec12fb83f36821eb2faf2cbe357a2876997605f74 /pkg/gui
parent6c0b805137dbed6d8d89d2e10cb7018776b55321 (diff)
migrate patch building tests
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/mergeconflicts/state.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/gui/mergeconflicts/state.go b/pkg/gui/mergeconflicts/state.go
index 384fb735f..a3dbcff3a 100644
--- a/pkg/gui/mergeconflicts/state.go
+++ b/pkg/gui/mergeconflicts/state.go
@@ -1,6 +1,8 @@
package mergeconflicts
import (
+ "strings"
+
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -188,9 +190,30 @@ func (s *State) ContentAfterConflictResolve(selection Selection) (bool, string,
func (s *State) GetSelectedLine() int {
conflict := s.currentConflict()
if conflict == nil {
+ // TODO: see why this is 1 and not 0
return 1
}
selection := s.Selection()
startIndex, _ := selection.bounds(conflict)
return startIndex + 1
}
+
+func (s *State) GetSelectedRange() (int, int) {
+ conflict := s.currentConflict()
+ if conflict == nil {
+ return 0, 0
+ }
+ selection := s.Selection()
+ startIndex, endIndex := selection.bounds(conflict)
+ return startIndex, endIndex
+}
+
+func (s *State) PlainRenderSelected() string {
+ startIndex, endIndex := s.GetSelectedRange()
+
+ content := s.GetContent()
+
+ contentLines := utils.SplitLines(content)
+
+ return strings.Join(contentLines[startIndex:endIndex+1], "\n")
+}