From f71b23b890014ce7eff01fd72ac50c672ed07ae9 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 5 Jun 2021 13:30:55 +1000 Subject: [PATCH] more explicit --- pkg/gui/mergeconflicts/find_conflicts.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pkg/gui/mergeconflicts/find_conflicts.go b/pkg/gui/mergeconflicts/find_conflicts.go index 2138215f1..848c05756 100644 --- a/pkg/gui/mergeconflicts/find_conflicts.go +++ b/pkg/gui/mergeconflicts/find_conflicts.go @@ -48,18 +48,14 @@ func findConflicts(content string) []*mergeConflict { func determineLineType(line string) LineType { trimmedLine := strings.TrimPrefix(line, "++") - mapping := map[string]LineType{ - "^<<<<<<< (HEAD|MERGE_HEAD|Updated upstream|ours)(:.+)?$": START, - "^=======$": MIDDLE, - "^>>>>>>> .*$": END, + switch { + case strings.HasPrefix(trimmedLine, "<<<<<<< "): + return START + case trimmedLine == "=======": + return MIDDLE + case strings.HasPrefix(trimmedLine, ">>>>>>> "): + return END + default: + return NOT_A_MARKER } - - for regexp_str, lineType := range mapping { - match, _ := regexp.MatchString(regexp_str, trimmedLine) - if match { - return lineType - } - } - - return NOT_A_MARKER }