git_spelunk 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -89,7 +89,7 @@ module GitSpelunk
89
89
  current_line_offset = parent_line_offset = diff_index = 0
90
90
 
91
91
  lines.each do |line|
92
- break if current_line_offset == target_line_offset
92
+ break if current_line_offset == target_line_offset && src_line?(line)
93
93
 
94
94
  if src_line?(line)
95
95
  current_line_offset += 1
@@ -101,11 +101,15 @@ module GitSpelunk
101
101
 
102
102
  diff_index += 1
103
103
  end
104
- # find last contiguous bit of diff
105
- line = lines[diff_index]
104
+
105
+ # find last contiguous bit of diff, and try to offset into that.
106
106
  removals = additions = 0
107
+ diff_index -= 1
108
+
109
+ while true
110
+ line = lines[diff_index]
111
+ break unless ["-", "+"].include?(line[0])
107
112
 
108
- while ["-", "+"].include?(line[0])
109
113
  if parent_line?(line)
110
114
  removals += 1
111
115
  else
@@ -113,12 +117,10 @@ module GitSpelunk
113
117
  end
114
118
 
115
119
  diff_index -= 1
116
- line = lines[diff_index]
117
120
  end
118
121
 
119
- forward_push = current_line_offset - additions
120
- forward_push = removals if forward_push > removals # clamp line matching
121
- parent_line_offset - removals + forward_push
122
+ forward_push = [additions, removals - 1].min
123
+ (parent_line_offset - removals) + forward_push
122
124
  end
123
125
 
124
126
  def src_line?(line)
@@ -20,9 +20,10 @@ module GitSpelunk
20
20
 
21
21
  def draw_status_line
22
22
  with_highlighting do
23
- @window.addstr("navigation: j k CTRL-D CTRL-U ")
24
- @window.addstr("history: [ ] ")
25
- @window.addstr("search: / ")
23
+ @window.addstr("navigation: j k CTRL-D CTRL-U ")
24
+ @window.addstr("history: [ ] ")
25
+ @window.addstr("search: / ? n N ")
26
+ @window.addstr("git-show: s ")
26
27
  @window.addstr(" " * line_remainder + "\n")
27
28
  end
28
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_spelunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-17 00:00:00.000000000 Z
13
+ date: 2013-11-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grit