Skip to content

Commit df81fa7

Browse files
committed
Fix handling of binary text files
1 parent 7aee795 commit df81fa7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,11 @@ export class VSCodeEffect {
11361136

11371137
if (activeEditor && activeEditor.getModel()) {
11381138
const modulePath = activeEditor.getModel().uri.path;
1139+
const currentModule = this.options.getCurrentModule();
11391140

1140-
activeEditor.updateOptions({ readOnly: this.readOnly });
1141+
activeEditor.updateOptions({
1142+
readOnly: this.readOnly || currentModule?.isBinary,
1143+
});
11411144

11421145
if (!modulePath.startsWith('/sandbox')) {
11431146
return;
@@ -1153,16 +1156,16 @@ export class VSCodeEffect {
11531156
);
11541157
}
11551158

1156-
const currentModule = this.options.getCurrentModule();
1157-
11581159
if (
11591160
currentModule &&
11601161
modulePath === `/sandbox${currentModule.path}` &&
11611162
currentModule.code !== undefined &&
1162-
activeEditor.getValue() !== currentModule.code
1163+
activeEditor.getValue() !== currentModule.code &&
1164+
!currentModule.isBinary
11631165
) {
11641166
// This means that the file in Cerebral is dirty and has changed,
11651167
// VSCode only gets saved contents. In this case we manually set the value correctly.
1168+
11661169
this.modelsHandler.isApplyingOperation = true;
11671170
const model = activeEditor.getModel();
11681171
model.applyEdits([

packages/app/src/app/overmind/namespaces/editor/internalActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const saveCode: AsyncAction<{
147147

148148
module.insertedAt = updatedModule.insertedAt;
149149
module.updatedAt = updatedModule.updatedAt;
150+
module.isBinary = updatedModule.isBinary;
150151

151152
const savedCode =
152153
updatedModule.code === module.code ? null : updatedModule.code;

0 commit comments

Comments
 (0)