From b13795b59caa4927bc16f8bbdb3d642872f2c9df Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 28 Mar 2024 23:28:56 +0100 Subject: [PATCH] Correct line numbers in stacktrace --- issues/templates/issues/issue_stacktrace.html | 3 ++- theme/templatetags/issues.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 theme/templatetags/issues.py diff --git a/issues/templates/issues/issue_stacktrace.html b/issues/templates/issues/issue_stacktrace.html index a99d426..877aeb1 100644 --- a/issues/templates/issues/issue_stacktrace.html +++ b/issues/templates/issues/issue_stacktrace.html @@ -1,6 +1,7 @@ {% extends "issues/base.html" %} {% load static %} {% load stricter_templates %} +{% load issues %} {% block tab_content %} {#
Stacktrace:
I think this is obvious?#} @@ -47,7 +48,7 @@
{# convience div for padding & border; the border is basically the top-border of the next header #}
{# code listing #} {# the spread-out pX-6 in this code is intentional to ensure the padding is visible when scrolling to the right, and not visible when scrolling is possible (i.e. the text is cut-off awkwardly to hint at scrolling #} -
    +
      {% for line in frame.pre_context %}
    1. {{ line }} {# leave space to avoid collapse #}
    2. {% endfor %} {# the gradient is a workaround, because I can't get a full-width elem going here inside the overflow #} {# when some other line is overflowing. Using the gradient hides this fact (it happens to also look good) #} diff --git a/theme/templatetags/issues.py b/theme/templatetags/issues.py new file mode 100644 index 0000000..1ad371a --- /dev/null +++ b/theme/templatetags/issues.py @@ -0,0 +1,7 @@ +from django import template +register = template.Library() + + +@register.filter(name='firstlineno') +def firstlineno(value): + return value['lineno'] - len(value['pre_context'])