(file, { forceOptions = false } = {})
| 1428 | } |
| 1429 | |
| 1430 | function applyCurrentEditorOptions(file, { forceOptions = false } = {}) { |
| 1431 | touchSelectionController?.onSessionChanged(); |
| 1432 | const optionsSignature = getEditorOptionsSignature(); |
| 1433 | if (forceOptions || file.__cmOptionsSignature !== optionsSignature) { |
| 1434 | const desiredTheme = appSettings?.value?.editorTheme; |
| 1435 | if (desiredTheme) editor.setTheme(desiredTheme); |
| 1436 | applyOptions(); |
| 1437 | file.__cmOptionsSignature = optionsSignature; |
| 1438 | } |
| 1439 | try { |
| 1440 | const ro = !file.editable || !!file.loading; |
| 1441 | editor.dispatch({ |
| 1442 | effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(ro)), |
| 1443 | }); |
| 1444 | file.session = editor.state; |
| 1445 | } catch (error) { |
| 1446 | warnRecoverable( |
| 1447 | "Failed to apply read-only compartment update.", |
| 1448 | error, |
| 1449 | "readonly-reconfigure", |
| 1450 | ); |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | function showLoadingEditor(file) { |
| 1455 | const loadingState = EditorState.create({ |
no test coverage detected