diff --git a/kittens/diff/config.py b/kittens/diff/config.py index 64ac3f390..ccb49e628 100644 --- a/kittens/diff/config.py +++ b/kittens/diff/config.py @@ -49,6 +49,7 @@ def syntax_aliases(raw): type_map = { 'syntax_aliases': syntax_aliases, + 'num_context_lines': int, } for name in ( diff --git a/kittens/diff/diff.conf b/kittens/diff/diff.conf index 65a38fa81..2cfa431cc 100644 --- a/kittens/diff/diff.conf +++ b/kittens/diff/diff.conf @@ -9,6 +9,9 @@ syntax_aliases pyj:py recipe:py # for a list of schemes. pygments_style default +# The number of lines of context to show around each change. +num_context_lines 3 + # Colors foreground black background white diff --git a/kittens/diff/main.py b/kittens/diff/main.py index 78f0739aa..c395a7c3f 100644 --- a/kittens/diff/main.py +++ b/kittens/diff/main.py @@ -50,7 +50,9 @@ class DiffHandler(Handler): self.report_traceback_on_exit = None self.args = args self.scroll_pos = self.max_scroll_pos = 0 - self.current_context_count = self.args.context + self.current_context_count = self.original_context_count = self.args.context + if self.current_context_count < 0: + self.current_context_count = self.original_context_count = self.opts.num_context_lines self.highlighting_done = False self.restore_position = None @@ -185,7 +187,7 @@ class DiffHandler(Handler): if text == 'a': new_ctx = 100000 elif text == '=': - new_ctx = 3 + new_ctx = self.original_context_count else: new_ctx += (-1 if text == '-' else 1) * 5 self.change_context_count(new_ctx) @@ -270,8 +272,9 @@ class DiffHandler(Handler): OPTIONS = partial('''\ --context type=int -default=3 -Number of lines of context to show between changes. +default=-1 +Number of lines of context to show between changes. Negative values +use the number set in diff.conf --config