diff --git a/docs/changelog.rst b/docs/changelog.rst index a07b42405..65e6d4d9f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -32,6 +32,10 @@ Changelog takes parameters so you can define your own shortcuts to clear the screen/scrollback also (:iss:`747`) +- diff kitten: Fix error when right hand side file is binary and left hand side + file is text (:iss:`752`) + + 0.11.3 [2018-07-10] ------------------------------ diff --git a/kittens/diff/main.py b/kittens/diff/main.py index 2512d68d2..fa839bcf7 100644 --- a/kittens/diff/main.py +++ b/kittens/diff/main.py @@ -42,7 +42,7 @@ def generate_diff(collection, context): for path, item_type, changed_path in collection: if item_type == 'diff': - is_binary = isinstance(data_for_path(path), bytes) + is_binary = isinstance(data_for_path(path), bytes) or isinstance(data_for_path(changed_path), bytes) if not is_binary: d.add_diff(path, changed_path) diff --git a/kittens/diff/render.py b/kittens/diff/render.py index 1a8421592..960e9aa7d 100644 --- a/kittens/diff/render.py +++ b/kittens/diff/render.py @@ -452,8 +452,8 @@ def render_diff(collection, diff_map, args, columns, image_manager): for i, (path, item_type, other_path) in enumerate(collection): item_ref = Reference(path) - is_binary = isinstance(data_for_path(path), bytes) - is_img = is_binary and is_image(path) and images_supported() + is_binary = isinstance(data_for_path(path), bytes) or (other_path and isinstance(data_for_path(other_path), bytes)) + is_img = is_binary and (is_image(path) or is_image(other_path)) and images_supported() yield from yield_lines_from(title_lines(path, other_path, args, columns, margin_size), item_ref, False) if item_type == 'diff': if is_binary: