diff --git a/kittens/diff/highlight.py b/kittens/diff/highlight.py index c159ff7e9..43b211881 100644 --- a/kittens/diff/highlight.py +++ b/kittens/diff/highlight.py @@ -122,8 +122,6 @@ def highlight_line(line): def highlight_for_diff(path, aliases): ans = [] lines = lines_for_path(path) - if len(lines) > 10000: - return ans hd = highlight_data('\n'.join(lines), path, aliases) if hd is not None: for line in hd.splitlines(): @@ -135,6 +133,7 @@ def highlight_collection(collection, aliases=None): jobs = {} ans = {} with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor: + highlight_collection.processes = executor._processes for path, item_type, other_path in collection: if item_type != 'rename': for p in (path, other_path): diff --git a/kittens/diff/main.py b/kittens/diff/main.py index fa839bcf7..f3819c295 100644 --- a/kittens/diff/main.py +++ b/kittens/diff/main.py @@ -3,6 +3,7 @@ # License: GPL v3 Copyright: 2018, Kovid Goyal import os +import signal import sys import warnings from collections import defaultdict @@ -508,6 +509,13 @@ help_text = 'Show a side-by-side diff of the specified files/directories' usage = 'file_or_directory_left file_or_directory_right' +def terminate_processes(processes): + for pid in processes: + os.kill(pid, signal.SIGTERM) + for pid in processes: + os.kill(pid, signal.SIGKILL) + + def main(args): warnings.showwarning = showwarning args, items = parse_args(args[1:], OPTIONS, usage, help_text, 'kitty +kitten diff') @@ -530,6 +538,8 @@ def main(args): for message in showwarning.warnings: from kitty.utils import safe_print safe_print(message, file=sys.stderr) + processes = getattr(highlight_collection, 'processes', ()) + terminate_processes(tuple(processes)) if loop.return_code != 0: if handler.report_traceback_on_exit: print(handler.report_traceback_on_exit, file=sys.stderr)