Skip to content

Commit bf58f6c

Browse files
Merge pull request #8830 from sagemathinc/fix-latex-error-popup-during-typing
fix(latex): suppress error toast when build/output/errors frame is visible
2 parents ef14a73 + cca8cfb commit bf58f6c

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

src/packages/frontend/frame-editors/latex-editor/actions.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,32 @@ export class Actions extends BaseActions<LatexEditorState> {
820820
return this._new_frame_tree_layout();
821821
}
822822

823+
// Frame types (EDITOR_SPEC keys) that already display build errors.
824+
// https://github.com/sagemathinc/cocalc/issues/8659
825+
private static ERROR_DISPLAY_FRAMES = [
826+
"output",
827+
"build",
828+
"error",
829+
] as const;
830+
831+
private hasErrorDisplayFrame(): boolean {
832+
try {
833+
const tree = this._get_tree();
834+
for (const id in this._get_leaf_ids()) {
835+
const node = tree_ops.get_node(tree, id);
836+
if (
837+
node != null &&
838+
(Actions.ERROR_DISPLAY_FRAMES as readonly string[]).includes(
839+
node.get("type"),
840+
)
841+
) {
842+
return true;
843+
}
844+
}
845+
} catch {}
846+
return false;
847+
}
848+
823849
check_for_fatal_error(): void {
824850
const build_logs: BuildLogs = this.store.get("build_logs");
825851
if (!build_logs) return;
@@ -841,7 +867,11 @@ export class Actions extends BaseActions<LatexEditorState> {
841867
"WARNING: It is not possible to generate a useful PDF file.\n" +
842868
s.trim();
843869
console.warn(err);
844-
this.set_error(err);
870+
// Only show toast if no error-displaying frame is visible —
871+
// if one is, the user can already see the problem there.
872+
if (!this.hasErrorDisplayFrame()) {
873+
this.set_error(err);
874+
}
845875
}
846876
}
847877

src/packages/frontend/frame-editors/latex-editor/output.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,20 @@ export function Output(props: OutputProps) {
505505

506506
function renderProblemsTab() {
507507
const { errors, warnings, typesetting } = errorCounts;
508-
509508
return {
510509
key: "problems",
511510
label: (
512-
<span style={LABEL_STYLE}>
511+
<span
512+
style={{
513+
...LABEL_STYLE,
514+
...(errors > 0
515+
? {
516+
backgroundColor: "rgba(255, 0, 0, 0.1)",
517+
borderRadius: "4px",
518+
}
519+
: undefined),
520+
}}
521+
>
513522
<Icon name="bug" style={{ marginRight: "0" }} />
514523
{intl.formatMessage(editor.errors_and_warnings_title_short)}
515524
{renderProblemsCounter(errors, warnings, typesetting)}

0 commit comments

Comments
 (0)