From 897e2224e04c245fd8dc77c3d363b0025cf56306 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Fri, 21 Feb 2025 14:13:45 +0100 Subject: [PATCH] Highlight trailing whitespaces in diffs --- osc/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osc/core.py b/osc/core.py index ca07dd2e..c2ebd171 100644 --- a/osc/core.py +++ b/osc/core.py @@ -1935,6 +1935,11 @@ def get_default_editor(): def format_diff_line(line): + # highlight trailing whitespaces + match = re.search(rb"(\s+)$", line) + if match: + line = line[:match.start(1)] + b"\x1b[41m" + line[match.start(1):] + b"\x1b[0m" + if line.startswith(b"+++ ") or line.startswith(b"--- ") or line.startswith(b"Index:"): line = b"\x1b[1m" + line + b"\x1b[0m" elif line.startswith(b"+"):