From f5499e32d8667122b0a51f97c596a71df0ba044c Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Fri, 8 Nov 2024 12:54:38 +0100 Subject: [PATCH] Fix wrong file numbers on macro stack frames --- frontend/components/ErrorMessage.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index f78f97978..fda5c52c1 100644 --- a/frontend/components/ErrorMessage.js +++ b/frontend/components/ErrorMessage.js @@ -8,9 +8,11 @@ import { open_bottom_right_panel } from "./BottomRightPanel.js" import AnsiUp from "../imports/AnsiUp.js" const extract_cell_id = (/** @type {string} */ file) => { - const sep_index = file.indexOf("#==#") + if (file.includes("#@#==#")) return null + const sep = "#==#" + const sep_index = file.indexOf(sep) if (sep_index != -1) { - return file.substring(sep_index + 4, sep_index + 4 + 36) + return file.substring(sep_index + sep.length, sep_index + sep.length + 36) } else { return null } @@ -60,22 +62,23 @@ const StackFrameFilename = ({ frame, cell_id }) => { if (ignore_location(frame)) return null const frame_cell_id = extract_cell_id(frame.file) + const line = frame.line if (frame_cell_id != null) { return html` { - focus_line(frame_cell_id, frame.line - 1) + focus_line(frame_cell_id, line == null ? null : line - 1) e.preventDefault() }} > - ${frame_cell_id == cell_id ? "This\xa0cell" : "Other\xa0cell"}: line ${frame.line} + ${frame_cell_id == cell_id ? "This\xa0cell" : "Other\xa0cell"}${line == null ? null : html`: line ${line}`} ` } else { const sp = frame.source_package const origin = ["Main", "Core", "Base"].includes(sp) ? "julia" : sp - const file_line = html`${frame.file}:${frame.line}` + const file_line = html`${frame.file.replace(/#@#==#.*/, "")}:${frame.line}` const text = sp != null ? html`${origin} → ${file_line}` : file_line