Correct line numbers in stacktrace

This commit is contained in:
Klaas van Schelven
2024-03-28 23:28:56 +01:00
parent 6f19528290
commit b13795b59c
2 changed files with 9 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
{% extends "issues/base.html" %}
{% load static %}
{% load stricter_templates %}
{% load issues %}
{% block tab_content %}
{# <div class="font-bold">Stacktrace:</div> I think this is obvious?#}
@@ -47,7 +48,7 @@
<div class="pl-6 pr-6 pt-8 {% if not forloop.last %}border-b-2{% endif %}">{# convience div for padding & border; the border is basically the top-border of the next header #}
<div class="bg-slate-50">{# 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 #}
<ol class="list-decimal overflow-x-auto list-inside pt-6 pb-6" start="100">
<ol class="list-decimal overflow-x-auto list-inside pt-6 pb-6" start="{{ frame|firstlineno }}">
{% for line in frame.pre_context %}<li class="pl-6"><div class="whitespace-pre w-full inline pr-6">{{ line }} {# leave space to avoid collapse #}</div></li>{% 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) #}

View File

@@ -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'])