mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-11 18:32:12 +02:00
Highlight changed in individual lines in chunks that have the same number of adds/removes
This commit is contained in:
@@ -21,3 +21,14 @@ class TestDiff(BaseTest):
|
||||
pc, sc = changed_center(left, right)
|
||||
for src in (left, right):
|
||||
self.assertEqual((prefix, suffix), (src[:pc], src[-sc:] if sc else ''))
|
||||
|
||||
def test_split_to_size(self):
|
||||
from kittens.diff.render import split_to_size_with_center
|
||||
for line, width, prefix_count, suffix_count, expected in [
|
||||
('abcdefgh', 20, 2, 3, ('abSScdeEEfgh',)),
|
||||
('abcdefgh', 20, 2, 0, ('abSScdefgh',)),
|
||||
('abcdefgh', 3, 2, 3, ('abSSc', 'SSdeEEf', 'gh')),
|
||||
('abcdefgh', 2, 4, 1, ('ab', 'cd', 'SSef', 'SSgEEh')),
|
||||
]:
|
||||
self.ae(expected, tuple(split_to_size_with_center(
|
||||
line, width, prefix_count, suffix_count, 'SS', 'EE')))
|
||||
|
||||
Reference in New Issue
Block a user