Skip to content

Commit d8af7e2

Browse files
committed
Add an option to control highlighting of moved lines
1 parent f45345c commit d8af7e2

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ Detailed list of changes
168168
0.46.1 [future]
169169
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170170

171+
- diff kitten: Highlight moved lines using a different background color (:opt:`kitten-diff.mark_moved_lines`) (:iss:`3241`)
172+
171173
- Fix a regression that broke ``kitten update-self`` (:iss:`9642`)
172174

173175
- macOS: Clear bell alert badge on dock icon on mouse/keyboard activity (:iss:`9640`)

kittens/diff/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def main(args: list[str]) -> None:
6565
''',
6666
)
6767

68+
opt('mark_moved_lines', 'yes', option_type='to_bool', long_text='''
69+
Highlight lines that are moved, that is removed from the left and added to the right
70+
differently, using the :opt:`moved_bg` color.''')
71+
6872
opt('word_diff_mode', 'words', choices=('words', 'central'),
6973
long_text='''
7074
The algorithm to use for highlighting which parts of changed lines differ.
@@ -153,10 +157,10 @@ def main(args: list[str]) -> None:
153157
opt('dark_added_margin_bg', '#31503d', option_type='to_color')
154158

155159
opt('moved_bg', '#fffde7', option_type='to_color', long_text='Moved text backgrounds (same text that was removed in one place and added in another)')
156-
opt('dark_moved_bg', '#2c2200', option_type='to_color')
160+
opt('dark_moved_bg', '#003333', option_type='to_color')
157161

158162
opt('moved_margin_bg', '#fff3b0', option_type='to_color')
159-
opt('dark_moved_margin_bg', '#4a3800', option_type='to_color')
163+
opt('dark_moved_margin_bg', '#00495b', option_type='to_color')
160164

161165
opt('filler_bg', '#fafbfc', option_type='to_color', long_text='Filler (empty) line background')
162166
opt('dark_filler_bg', '#262c36', option_type='to_color')

kittens/diff/patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ func parse_patch(raw string, left_lines, right_lines []string) (ans *Patch, err
544544
ans.largest_line_number = ans.all_hunks[len(ans.all_hunks)-1].largest_line_number
545545
}
546546
err = ans.compute_centers(left_lines, right_lines)
547-
if err == nil {
547+
if err == nil && conf.Mark_moved_lines {
548548
ans.detect_moved_lines(left_lines, right_lines)
549549
}
550550
return

kittens/diff/render.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,9 @@ type DiffData struct {
547547
left_path, right_path string
548548
available_cols, margin_size int
549549

550-
left_lines, right_lines []string
551-
left_moved_lines *utils.Set[int]
552-
right_moved_lines *utils.Set[int]
550+
left_lines, right_lines []string
551+
left_moved_lines *utils.Set[int]
552+
right_moved_lines *utils.Set[int]
553553
}
554554

555555
func hunk_title(hunk *Hunk) string {

0 commit comments

Comments
 (0)