Skip to content

Commit fe701af

Browse files
authored
Merge pull request #7877 from sagemathinc/fix-latex-build-20240925
frontend/latex: fix "help me fix" in gutter
2 parents a2e175b + ff9cc93 commit fe701af

File tree

1 file changed

+45
-36
lines changed
  • src/packages/frontend/frame-editors/latex-editor

1 file changed

+45
-36
lines changed

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

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// one gets a gutter mark, with pref to errors. The main error log shows everything, so this should be OK.
1010

1111
import { Popover } from "antd";
12+
import { IntlProvider } from "react-intl";
1213

1314
import { Icon } from "@cocalc/frontend/components";
1415
//import { Actions } from "@cocalc/frontend/frame-editors/code-editor/actions";
@@ -17,6 +18,7 @@ import { capitalize } from "@cocalc/util/misc";
1718
import { Actions } from "./actions";
1819
import { SPEC, SpecItem } from "./errors-and-warnings";
1920
import { Error, IProcessedLatexLog } from "./latex-log-parser";
21+
import { DEFAULT_LOCALE } from "@cocalc/frontend/i18n";
2022

2123
export function update_gutters(opts: {
2224
log: IProcessedLatexLog;
@@ -63,42 +65,49 @@ function component(
6365
}
6466
// NOTE/BUG: despite allow_touch true below, this still does NOT work on my iPad -- we see the icon, but nothing
6567
// happens when clicking on it; this may be a codemirror issue.
68+
// NOTE: the IntlProvider is necessary, because this is mounted outside the application's overall context.
69+
// It's just a default IntlProvider to avoid a crash → TODO: make this part of the application react root.
6670
return (
67-
<Popover
68-
title={message}
69-
content={
70-
<div>
71-
{content}
72-
{group == "errors" && (
73-
<>
74-
<br />
75-
<HelpMeFix
76-
size="small"
77-
style={{ marginTop: "5px" }}
78-
task={"ran latex"}
79-
error={content}
80-
input={() => {
81-
const s = actions._syncstring.to_str();
82-
const v = s
83-
.split("\n")
84-
.slice(0, line + 1)
85-
.join("\n");
86-
//line+1 since lines are 1-based
87-
return v + `% this is line number ${line + 1}`;
88-
}}
89-
language={"latex"}
90-
extraFileInfo={actions.languageModelExtraFileInfo()}
91-
tag={"latex-error-popover"}
92-
prioritize="end"
93-
/>
94-
</>
95-
)}
96-
</div>
97-
}
98-
placement={"right"}
99-
mouseEnterDelay={0}
100-
>
101-
<Icon name={spec.icon} style={{ color: spec.color, cursor: "pointer" }} />
102-
</Popover>
71+
<IntlProvider locale="en" defaultLocale={DEFAULT_LOCALE}>
72+
<Popover
73+
title={message}
74+
content={
75+
<div>
76+
{content}
77+
{group == "errors" && (
78+
<>
79+
<br />
80+
<HelpMeFix
81+
size="small"
82+
style={{ marginTop: "5px" }}
83+
task={"ran latex"}
84+
error={content}
85+
input={() => {
86+
const s = actions._syncstring.to_str();
87+
const v = s
88+
.split("\n")
89+
.slice(0, line + 1)
90+
.join("\n");
91+
//line+1 since lines are 1-based
92+
return v + `% this is line number ${line + 1}`;
93+
}}
94+
language={"latex"}
95+
extraFileInfo={actions.languageModelExtraFileInfo()}
96+
tag={"latex-error-popover"}
97+
prioritize="end"
98+
/>
99+
</>
100+
)}
101+
</div>
102+
}
103+
placement={"right"}
104+
mouseEnterDelay={0}
105+
>
106+
<Icon
107+
name={spec.icon}
108+
style={{ color: spec.color, cursor: "pointer" }}
109+
/>
110+
</Popover>
111+
</IntlProvider>
103112
);
104113
}

0 commit comments

Comments
 (0)