Skip to content

Commit 630e6a1

Browse files
committed
add python-coverage-overlay-width defcustom
1 parent a987554 commit 630e6a1

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

python-coverage.el

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
:group 'python-coverage
3636
:type 'string)
3737

38+
(defcustom python-coverage-overlay-width nil
39+
"Maximum width of the overlays.
40+
41+
If nil, highlight the whole statement. If a number, highlight up
42+
to that number of characters, or until the end of line, whichever
43+
comes first. Practically, a small number such as 2 will result in
44+
non-obtrusive colored blocks adjacent to the left margin."
45+
:group 'python-coverage
46+
:type '(choice integer (const :tag "Complete line" nil)))
47+
3848
(defface python-coverage-overlay-missing
3949
'((t :inherit magit-diff-removed))
4050
"Overlay face for missing coverage."
@@ -313,10 +323,19 @@ If OUTDATED is non-nil, use a different style."
313323
(point)))
314324
(end
315325
(save-excursion
316-
(widen)
317326
(goto-char beg)
318-
(python-nav-end-of-statement)
319-
(1+ (point))))
327+
(if python-coverage-overlay-width
328+
(min
329+
(line-end-position)
330+
(progn
331+
(forward-char python-coverage-overlay-width)
332+
(point)))
333+
(python-nav-end-of-statement)
334+
(1+ (point)))))
335+
(end
336+
;; At least one character. This should only happen for
337+
;; outdated overlays on empty lines.
338+
(max end (1+ beg)))
320339
(face
321340
(pcase status
322341
('missing

0 commit comments

Comments
 (0)