Debian Codegraph @

testdata/conflict-with-context.riff-output

raw
1 diff --cc m/search.go
2 index 5b67346,e5b580f..0000000
3 --- m/search.go
4 +++ m/search.go
5 @@@ -10,45 -6,9 +10,79 @@@ import 
6 "github.com/walles/moar/m/linenumbers"
7 )
8
9 ++<<<<<<< HEAD
10  +func (p *Pager) scrollToSearchHits() {
11  + if p.searchPattern == nil {
12  + // This is not a search
13  + return
14  + }
15  +
16  + lineNumber := p.scrollPosition.lineNumber(p)
17  + if lineNumber == nil {
18  + // No lines to search
19  + return
20  + }
21  +
22  + firstHitPosition := p.findFirstHit(*lineNumber, nil, false)
23  + if firstHitPosition == nil && (*lineNumber != linenumbers.LineNumber{}) {
24  + // Try again from the top
25  + firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, lineNumber, false)
26  + }
27  + if firstHitPosition == nil {
28  + // No match, give up
29  + return
30  + }
31  +
32  + if firstHitPosition.isVisible(p) {
33  + // Already on-screen, never mind
34  + return
35  + }
36  +
37  + p.scrollPosition = *firstHitPosition
38  +}
39  +
40  +// NOTE: When we search, we do that by looping over the *input lines*, not the
41  +// screen lines. That's why startPosition is a LineNumber rather than a
42  +// scrollPosition.
43  +//
44  +// The `beforePosition` parameter is exclusive, meaning that line will not be
45  +// searched.
46  +//
47  +// For the actual searching, this method will call _findFirstHit() in parallel
48  +// on multiple cores, to help large file search performance.
49 ++||||||| parent of b835e9a (Fix the warnings)
50 ++func (p *Pager) scrollToSearchHits() {
51 ++ if p.searchPattern == nil {
52 ++ // This is not a search
53 ++ return
54 ++ }
55 ++
56 ++ firstHitPosition := p.findFirstHit(*p.scrollPosition.lineNumber(p), nil, false)
57 ++ if firstHitPosition == nil {
58 ++ // Try again from the top
59 ++ firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, p.scrollPosition.lineNumber(p), false)
60 ++ }
61 ++ if firstHitPosition == nil {
62 ++ // No match, give up
63 ++ return
64 ++ }
65 ++
66 ++ if firstHitPosition.isVisible(p) {
67 ++ // Already on-screen, never mind
68 ++ return
69 ++ }
70 ++
71 ++ p.scrollPosition = *firstHitPosition
72 ++}
73 ++
74 + // NOTE: When we search, we do that by looping over the *input lines*, not
75 + // the screen lines. That's why we're using a line number rather than a
76 + // scrollPosition for searching.
77 ++=======
78 + // NOTE: When we search, we do that by looping over the *input lines*, not
79 + // the screen lines. That's why we're using a line number rather than a
80 + // scrollPosition for searching.
81 ++>>>>>>> b835e9a (Fix the warnings)
82 //
83 // FIXME: We should take startPosition.deltaScreenLines into account as well!
84 func (p *Pager) findFirstHit(startPosition linenumbers.LineNumber, beforePosition *linenumbers.LineNumber, backwards bool) *scrollPosition {