diff --git a/SCREENSHOTS.md b/SCREENSHOTS.md index 7051214..935097e 100644 --- a/SCREENSHOTS.md +++ b/SCREENSHOTS.md @@ -1,8 +1,11 @@ -To update `screenshot-git-merge.png`, you should be running -[iTerm2](https://iterm2.com/) and have [`moar`](https://github.com/walles/moar) -as your pager. +# Screenshot updating instructions -Then: +Screenshots are done using: + +- Terminal: [iTerm2](https://iterm2.com/) +- Pager: [`moar`](https://github.com/walles/moar) + +## `screenshot-git-merge.png` 1. Scale your terminal window to 65x17 2. Copy the below example to the clipboard @@ -25,3 +28,9 @@ index 0399cd5,59727f0..0000000 hello() ``` + +## `screenshot-diff2-conflict.png` + +1. Scale your window to 72x10 +2. `cargo run < testdata/conflict-markers.txt.riff-output` +3. Screenshot the window and store it as `screenshot-diff2-conflict.png` diff --git a/screenshot-diff2-conflict.png b/screenshot-diff2-conflict.png index 2d258d4..8100e71 100644 Binary files a/screenshot-diff2-conflict.png and b/screenshot-diff2-conflict.png differ diff --git a/src/conflicts_highlighter.rs b/src/conflicts_highlighter.rs index 123690f..3bc64f8 100644 --- a/src/conflicts_highlighter.rs +++ b/src/conflicts_highlighter.rs @@ -174,7 +174,7 @@ impl ConflictsHighlighter { let (header_prefix, c1_prefix, c2_prefix, reset) = if self.c1_header.starts_with("++") { (INVERSE_VIDEO, " +", "+ ", NORMAL) } else { - ("", "", "", "") + (INVERSE_VIDEO, "", "", "") }; let c1_header = self.c1_header.clone(); diff --git a/testdata/conflict-markers-diff3-baseless.txt.riff-output b/testdata/conflict-markers-diff3-baseless.txt.riff-output index 29cfdf5..74ae24d 100644 --- a/testdata/conflict-markers-diff3-baseless.txt.riff-output +++ b/testdata/conflict-markers-diff3-baseless.txt.riff-output @@ -1,8 +1,8 @@ This is an example of git conflict markers. -<<<<<<< HEAD -This line was added on the main branch. -||||||| 07ffb9b -======= -This line was added on the branch named "branch". ->>>>>>> branch +<<<<<<< HEAD +This line was added on the main branch. +||||||| 07ffb9b +======= +This line was added on the branch named "branch". +>>>>>>> branch diff --git a/testdata/conflict-markers-diff3-removed.txt.riff-output b/testdata/conflict-markers-diff3-removed.txt.riff-output index fc332bf..932369b 100644 --- a/testdata/conflict-markers-diff3-removed.txt.riff-output +++ b/testdata/conflict-markers-diff3-removed.txt.riff-output @@ -1,8 +1,8 @@ This is an example of git conflict markers. -<<<<<<< HEAD -This line is changed on the main branch. -||||||| 07ffb9b -This line is from the initial commit on the main branch. -======= ->>>>>>> branch +<<<<<<< HEAD +This line is changed on the main branch. +||||||| 07ffb9b +This line is from the initial commit on the main branch. +======= +>>>>>>> branch diff --git a/testdata/conflict-markers-diff3.txt.riff-output b/testdata/conflict-markers-diff3.txt.riff-output index ce96db6..fcb362f 100644 --- a/testdata/conflict-markers-diff3.txt.riff-output +++ b/testdata/conflict-markers-diff3.txt.riff-output @@ -1,9 +1,9 @@ This is an example of git conflict markers. -<<<<<<< HEAD -This line is changed on the main branch. -||||||| 07ffb9b -This line is from the initial commit on the main branch. -======= -This line is from the branch named "branch". ->>>>>>> branch +<<<<<<< HEAD +This line is changed on the main branch. +||||||| 07ffb9b +This line is from the initial commit on the main branch. +======= +This line is from the branch named "branch". +>>>>>>> branch diff --git a/testdata/conflict-markers.txt.riff-output b/testdata/conflict-markers.txt.riff-output index 464178b..4b5796d 100644 --- a/testdata/conflict-markers.txt.riff-output +++ b/testdata/conflict-markers.txt.riff-output @@ -1,7 +1,7 @@ This is an example of git conflict markers. -<<<<<<< HEAD -This line is changed on the main branch. -======= -This line is from the branch named "branch". ->>>>>>> branch +<<<<<<< HEAD +This line is changed on the main branch. +======= +This line is from the branch named "branch". +>>>>>>> branch diff --git a/testdata/conflict-with-context.riff-output b/testdata/conflict-with-context.riff-output index 34b174c..b729bbf 100644 --- a/testdata/conflict-with-context.riff-output +++ b/testdata/conflict-with-context.riff-output @@ -6,79 +6,79 @@ "github.com/walles/moar/m/linenumbers" ) -++<<<<<<< HEAD - +func (p *Pager) scrollToSearchHits() { - + if p.searchPattern == nil { - + // This is not a search - + return - + } - + - + lineNumber := p.scrollPosition.lineNumber(p) - + if lineNumber == nil { - + // No lines to search - + return - + } - + - + firstHitPosition := p.findFirstHit(*lineNumber, nil, false) - + if firstHitPosition == nil && (*lineNumber != linenumbers.LineNumber{}) { - + // Try again from the top - + firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, lineNumber, false) - + } - + if firstHitPosition == nil { - + // No match, give up - + return - + } - + - + if firstHitPosition.isVisible(p) { - + // Already on-screen, never mind - + return - + } - + - + p.scrollPosition = *firstHitPosition - +} - + - +// NOTE: When we search, we do that by looping over the *input lines*, not the - +// screen lines. That's why startPosition is a LineNumber rather than a - +// scrollPosition. - +// - +// The `beforePosition` parameter is exclusive, meaning that line will not be - +// searched. - +// - +// For the actual searching, this method will call _findFirstHit() in parallel - +// on multiple cores, to help large file search performance. -++||||||| parent of b835e9a (Fix the warnings) -++func (p *Pager) scrollToSearchHits() { -++ if p.searchPattern == nil { -++ // This is not a search -++ return -++ } -++ -++ firstHitPosition := p.findFirstHit(*p.scrollPosition.lineNumber(p), nil, false) -++ if firstHitPosition == nil { -++ // Try again from the top -++ firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, p.scrollPosition.lineNumber(p), false) -++ } -++ if firstHitPosition == nil { -++ // No match, give up -++ return -++ } -++ -++ if firstHitPosition.isVisible(p) { -++ // Already on-screen, never mind -++ return -++ } -++ -++ p.scrollPosition = *firstHitPosition -++} -++ -++// NOTE: When we search, we do that by looping over the *input lines*, not -++// the screen lines. That's why we're using a line number rather than a -++// scrollPosition for searching. -++======= -+ // NOTE: When we search, we do that by looping over the *input lines*, not -+ // the screen lines. That's why we're using a line number rather than a -+ // scrollPosition for searching. -++>>>>>>> b835e9a (Fix the warnings) +++<<<<<<< HEAD + +func (p *Pager) scrollToSearchHits() { + + if p.searchPattern == nil { + + // This is not a search + + return + + } + + + + lineNumber := p.scrollPosition.lineNumber(p) + + if lineNumber == nil { + + // No lines to search + + return + + } + + + + firstHitPosition := p.findFirstHit(*lineNumber, nil, false) + + if firstHitPosition == nil && (*lineNumber != linenumbers.LineNumber{}) { + + // Try again from the top + + firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, lineNumber, false) + + } + + if firstHitPosition == nil { + + // No match, give up + + return + + } + + + + if firstHitPosition.isVisible(p) { + + // Already on-screen, never mind + + return + + } + + + + p.scrollPosition = *firstHitPosition + +} + + + +// NOTE: When we search, we do that by looping over the *input lines*, not the + +// screen lines. That's why startPosition is a LineNumber rather than a + +// scrollPosition. + +// + +// The `beforePosition` parameter is exclusive, meaning that line will not be + +// searched. + +// + +// For the actual searching, this method will call _findFirstHit() in parallel + +// on multiple cores, to help large file search performance. +++||||||| parent of b835e9a (Fix the warnings) +++func (p *Pager) scrollToSearchHits() { +++ if p.searchPattern == nil { +++ // This is not a search +++ return +++ } +++ +++ firstHitPosition := p.findFirstHit(*p.scrollPosition.lineNumber(p), nil, false) +++ if firstHitPosition == nil { +++ // Try again from the top +++ firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, p.scrollPosition.lineNumber(p), false) +++ } +++ if firstHitPosition == nil { +++ // No match, give up +++ return +++ } +++ +++ if firstHitPosition.isVisible(p) { +++ // Already on-screen, never mind +++ return +++ } +++ +++ p.scrollPosition = *firstHitPosition +++} +++ +++// NOTE: When we search, we do that by looping over the *input lines*, not +++// the screen lines. That's why we're using a line number rather than a +++// scrollPosition for searching. +++======= ++ // NOTE: When we search, we do that by looping over the *input lines*, not ++ // the screen lines. That's why we're using a line number rather than a ++ // scrollPosition for searching. +++>>>>>>> b835e9a (Fix the warnings) // // FIXME: We should take startPosition.deltaScreenLines into account as well! func (p *Pager) findFirstHit(startPosition linenumbers.LineNumber, beforePosition *linenumbers.LineNumber, backwards bool) *scrollPosition { diff --git a/testdata/git-diff-conflict-diff3-edit-remove.diff b/testdata/git-diff-conflict-diff3-edit-remove.diff new file mode 100644 index 0000000..0a2e519 --- /dev/null +++ b/testdata/git-diff-conflict-diff3-edit-remove.diff @@ -0,0 +1,16 @@ +diff --cc lines.txt +index 97515f1,f42366c..0000000 +--- lines.txt ++++ lines.txt +@@@ -1,3 -1,6 +1,11 @@@ + First line +++<<<<<<< HEAD +++||||||| 3b5ce9b +++Caesar +++======= ++ Adam ++ Bertil ++ Caesar +++>>>>>>> branch + Last line + diff --git a/testdata/git-diff-conflict-diff3-edit-remove.riff-output b/testdata/git-diff-conflict-diff3-edit-remove.riff-output new file mode 100644 index 0000000..419df3f --- /dev/null +++ b/testdata/git-diff-conflict-diff3-edit-remove.riff-output @@ -0,0 +1,16 @@ +diff --cc lines.txt +index 97515f1,f42366c..0000000 +--- lines.txt ++++ lines.txt +@@@ -1,3 -1,6 +1,11 @@@ + First line +++<<<<<<< HEAD +++||||||| 3b5ce9b +++Caesar +++======= ++ Adam ++ Bertil ++ Caesar +++>>>>>>> branch + Last line + diff --git a/testdata/git-diff-conflict-diff3.riff-output b/testdata/git-diff-conflict-diff3.riff-output index df9e430..d4a9a2c 100644 --- a/testdata/git-diff-conflict-diff3.riff-output +++ b/testdata/git-diff-conflict-diff3.riff-output @@ -5,10 +5,10 @@ @@@ -1,3 -1,3 +1,9 @@@ This is an example of git conflict markers. -++<<<<<<< HEAD - +This line is changed on the main branch. -++||||||| c26bbf8 -++This line is from the initial commit on the main branch. -++======= -+ This line is from the branch named "branch". -++>>>>>>> branch +++<<<<<<< HEAD + +This line is changed on the main branch. +++||||||| c26bbf8 +++This line is from the initial commit on the main branch. +++======= ++ This line is from the branch named "branch". +++>>>>>>> branch diff --git a/testdata/git-diff-conflict.riff-output b/testdata/git-diff-conflict.riff-output index 3e71897..c36a7a3 100644 --- a/testdata/git-diff-conflict.riff-output +++ b/testdata/git-diff-conflict.riff-output @@ -5,8 +5,8 @@ @@@ -1,3 -1,3 +1,7 @@@ This is an example of git conflict markers. -++<<<<<<< HEAD - +This line is changed on the main branch. -++======= -+ This line is from the branch named "branch". -++>>>>>>> branch +++<<<<<<< HEAD + +This line is changed on the main branch. +++======= ++ This line is from the branch named "branch". +++>>>>>>> branch diff --git a/testdata/git-rebase-unmerged.riff-output b/testdata/git-rebase-unmerged.riff-output index 3d61e27..53db822 100644 --- a/testdata/git-rebase-unmerged.riff-output +++ b/testdata/git-rebase-unmerged.riff-output @@ -6,60 +6,60 @@ - zfsbootmenu state: present -++<<<<<<< HEAD -++======= -+ - name: Create ESP mdadm config -+ template: -+ src: mdadm.conf.j2 -+ dest: /etc/mdadm.conf -+ owner: root -+ group: root -+ mode: 0644 -+ when: esp_mdadm_array is defined -+  -+ - name: Install dropbear -+ xbps: -+ pkg: -+ - dropbear -+ - mkinitcpio-dropbear -+ state: present -+  -+ - name: Create dropbear directory -+ file: -+ path: /etc/dropbear -+ owner: root -+ group: root -+ mode: 0755 -+ state: directory -+  -+ - name: Create dropbear keys -+ command: -+ cmd: /usr/bin/dropbearkey -t {{ item }} -f /etc/dropbear/dropbear_{{ item }}_host_key -+ creates: /etc/dropbear/dropbear_{{ item }}_host_key -+ loop: -+ - rsa -+ - ecdsa -+ - ed25519 -+  -+ - name: Create dropbear authorised keys -+ template: -+ src: authorized_keys.j2 -+ dest: /etc/dropbear/root_key -+ owner: root -+ group: root -+ mode: 0644 -+ lstrip_blocks: true -+  -+ - name: Create dropbear config -+ template: -+ src: dropbear.conf.j2 -+ dest: /etc/dropbear/dropbear.conf -+ owner: root -+ group: root -+ mode: 0644 -+ lstrip_blocks: true -+  -++>>>>>>> 8eec118 (fixup! ansible/roles/zfsbootmenu: add role) +++<<<<<<< HEAD +++======= ++ - name: Create ESP mdadm config ++  template: ++  src: mdadm.conf.j2 ++  dest: /etc/mdadm.conf ++  owner: root ++  group: root ++  mode: 0644 ++  when: esp_mdadm_array is defined ++  ++ - name: Install dropbear ++  xbps: ++  pkg: ++  - dropbear ++  - mkinitcpio-dropbear ++  state: present ++  ++ - name: Create dropbear directory ++  file: ++  path: /etc/dropbear ++  owner: root ++  group: root ++  mode: 0755 ++  state: directory ++  ++ - name: Create dropbear keys ++  command: ++  cmd: /usr/bin/dropbearkey -t {{ item }} -f /etc/dropbear/dropbear_{{ item }}_host_key ++  creates: /etc/dropbear/dropbear_{{ item }}_host_key ++  loop: ++  - rsa ++  - ecdsa ++  - ed25519 ++  ++ - name: Create dropbear authorised keys ++  template: ++  src: authorized_keys.j2 ++  dest: /etc/dropbear/root_key ++  owner: root ++  group: root ++  mode: 0644 ++  lstrip_blocks: true ++  ++ - name: Create dropbear config ++  template: ++  src: dropbear.conf.j2 ++  dest: /etc/dropbear/dropbear.conf ++  owner: root ++  group: root ++  mode: 0644 ++  lstrip_blocks: true ++  +++>>>>>>> 8eec118 (fixup! ansible/roles/zfsbootmenu: add role) - name: Create zfsbootmenu config template: src: config.yaml.j2