Allow setting the number of context lines in diff.conf

This commit is contained in:
Kovid Goyal 2018-05-08 23:17:40 +05:30
parent 9bf2087b55
commit 196bd9c22b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 11 additions and 4 deletions

View File

@ -49,6 +49,7 @@ def syntax_aliases(raw):
type_map = {
'syntax_aliases': syntax_aliases,
'num_context_lines': int,
}
for name in (

View File

@ -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

View File

@ -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