Skip to content

Commit 25ec897

Browse files
committed
fix #7958 -- user setting: make it so it is an explicit user setting whether you see your own cursor
1 parent bcd7ed1 commit 25ec897

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/packages/frontend/account/editor-settings/checkboxes.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ const EDITOR_SETTINGS_CHECKBOXES = {
8383
id: "account.editor-setting.checkbox.ask_jupyter_kernel",
8484
defaultMessage: "ask which kernel to use for a new Jupyter Notebook",
8585
}),
86-
show_my_other_cursors:
87-
"when editing the same file in mutiple browsers, show my other cursors",
86+
show_my_other_cursors: "when editing the same file in multiple browsers",
8887
disable_jupyter_virtualization: defineMessage({
8988
id: "account.editor-setting.checkbox.disable_jupyter_virtualization",
9089
defaultMessage:

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,13 +1148,19 @@ export class Actions<
11481148
// TODO: for now, just for the one syncstring obviously
11491149
// TOOD: this is probably naive and slow too...
11501150
let cursors: Map<string, List<Map<string, any>>> = Map();
1151-
this._syncstring.get_cursors().forEach((info, account_id) => {
1152-
info.get("locs").forEach((loc) => {
1153-
loc = loc.set("time", info.get("time"));
1154-
const locs = cursors.get(account_id, List()).push(loc);
1155-
cursors = cursors.set(account_id, locs as any);
1151+
this._syncstring
1152+
.get_cursors({
1153+
excludeSelf: !redux
1154+
.getStore("account")
1155+
.getIn(["editor_settings", "show_my_other_cursors"]),
1156+
})
1157+
.forEach((info, account_id) => {
1158+
info.get("locs").forEach((loc) => {
1159+
loc = loc.set("time", info.get("time"));
1160+
const locs = cursors.get(account_id, List()).push(loc);
1161+
cursors = cursors.set(account_id, locs as any);
1162+
});
11561163
});
1157-
});
11581164
if (!cursors.equals(this.store.get("cursors"))) {
11591165
this.setState({ cursors });
11601166
}
@@ -1191,7 +1197,10 @@ export class Actions<
11911197
return;
11921198
}
11931199
const omit_lines: SetMap = {};
1194-
const cursors = this._syncstring.get_cursors?.(); // there are situations where get_cursors isn't defined (seen this).
1200+
const cursors = this._syncstring.get_cursors?.({
1201+
excludeSelf: false,
1202+
maxAge: 3 * 60 * 1000,
1203+
}); // there are situations where get_cursors isn't defined (seen this).
11951204
if (cursors) {
11961205
cursors.map((user, _) => {
11971206
const locs = user.get("locs");

src/packages/frontend/jupyter/browser-actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ export class JupyterActions extends JupyterActions0 {
326326
) {
327327
return;
328328
}
329-
const cursors = this.syncdb.get_cursors();
329+
const excludeSelf = !this.redux
330+
.getStore("account")
331+
.getIn(["editor_settings", "show_my_other_cursors"]);
332+
const cursors = this.syncdb.get_cursors({ excludeSelf });
330333
const cells = this.cursor_manager.process(this.store.get("cells"), cursors);
331334
if (cells != null) {
332335
this.setState({ cells });

0 commit comments

Comments
 (0)