Skip to content

Commit c85f74a

Browse files
committed
Merge remote-tracking branch 'origin/master' into sso-exclusive-all
2 parents 681f6b9 + c2c9744 commit c85f74a

File tree

16 files changed

+107
-28
lines changed

16 files changed

+107
-28
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { set, get, del } from "@cocalc/frontend/misc/local-storage-typed";
2+
import { isEqual } from "lodash";
3+
4+
export function getFoldedLines(cm): number[] {
5+
if (cm?.foldCode == null) {
6+
// not enabled
7+
return [];
8+
}
9+
return cm
10+
.getAllMarks()
11+
.filter((mark) => mark.__isFold)
12+
.map((mark) => mark.find().from.line);
13+
}
14+
15+
export function setFoldedLines(cm, lines: number[]) {
16+
if (cm?.foldCode == null) {
17+
// not enabled
18+
return;
19+
}
20+
lines.reverse();
21+
for (const n of lines) {
22+
cm.foldCode(n);
23+
}
24+
}
25+
26+
function toKey(key: string): string {
27+
return `cmfold-${key}`;
28+
}
29+
30+
export function initFold(cm, key: string) {
31+
const k = toKey(key);
32+
const lines = get<number[]>(k);
33+
if (lines != null) {
34+
try {
35+
setFoldedLines(cm, lines);
36+
} catch (err) {
37+
console.warn(`error setting cold folding for ${key}: `, err);
38+
del(k);
39+
}
40+
}
41+
}
42+
43+
export function saveFold(cm, key: string) {
44+
const k = toKey(key);
45+
const lines = get<number[]>(k);
46+
const lines2 = getFoldedLines(cm);
47+
if (lines2.length == 0) {
48+
if (lines != null) {
49+
del(k);
50+
}
51+
return;
52+
}
53+
if (!isEqual(lines, lines2)) {
54+
set<number[]>(k, lines2);
55+
}
56+
}

src/packages/frontend/components/link-retry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface Props {
2424
onClick?: () => void;
2525
autoStart?: boolean;
2626
maxTime?: number;
27-
tooltip?: string;
27+
tooltip?: React.ReactNode;
2828
}
2929

3030
const LinkRetry: React.FC<Props> = ({

src/packages/frontend/frame-editors/code-editor/codemirror-editor.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { GutterMarkers } from "./codemirror-gutter-markers";
3636
import { Actions } from "./actions";
3737
import { EditorState } from "../frame-tree/types";
3838
import { Path } from "../frame-tree/path";
39+
import { initFold, saveFold } from "@cocalc/frontend/codemirror/util";
3940

4041
const STYLE = {
4142
width: "100%",
@@ -290,6 +291,16 @@ export const CodemirrorEditor: React.FC<Props> = React.memo((props) => {
290291
}
291292
cmRef.current.setOption("readOnly", props.read_only);
292293
cm_refresh();
294+
295+
const foldKey = `${props.path}\\${props.id}`;
296+
const saveFoldState = () => {
297+
if (cmRef.current != null) {
298+
saveFold(cmRef.current,foldKey);
299+
}
300+
};
301+
cmRef.current.on("fold" as any, saveFoldState);
302+
cmRef.current.on("unfold" as any, saveFoldState);
303+
initFold(cmRef.current, foldKey);
293304
}
294305

295306
function init_new_codemirror(): void {

src/packages/frontend/frame-editors/frame-tree/frame-tree.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ export const FrameTree: React.FC<FrameTreeProps> = React.memo(
290290
let name_leaf = name;
291291
let actions_leaf = actions;
292292
if (
293-
spec.name === "TimeTravel" &&
293+
typeof spec.name != "string" &&
294+
spec.name?.id === "labels.timetravel" &&
294295
!(actions instanceof TimeTravelActions)
295296
) {
296297
if (path_leaf.slice(path_leaf.length - 12) != ".time-travel") {

src/packages/frontend/i18n/bin/common.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/compile.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/download.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/extract.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/upload.sh

100644100755
File mode changed.

src/packages/frontend/i18n/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export const labels = defineMessages({
157157
description: "The button to engage with the AI Assistant dialog",
158158
},
159159
timetravel: {
160+
// DO NOT CHANGE THIS labels.timetravel ID!!!! It is explcitly used in frontend/frame-editors/frame-tree/frame-tree.tsx
161+
// This caused a massive bug when i18n was first merged.
160162
id: "labels.timetravel",
161163
defaultMessage: "TimeTravel",
162164
description:

0 commit comments

Comments
 (0)