Skip to content

Commit 8281fa7

Browse files
committed
do not attempt edit operation for for read-only editors
fixes #53257
1 parent 1cd7544 commit 8281fa7

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

src/vs/editor/common/services/resolverService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ export interface ITextEditorModel extends IEditorModel {
4242
* Provides access to the underlying `ITextModel`.
4343
*/
4444
textEditorModel: ITextModel;
45+
46+
isReadonly(): boolean;
4547
}

src/vs/editor/standalone/browser/simpleServices.ts

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export class SimpleModel implements ITextEditorModel {
6969
return this.model;
7070
}
7171

72+
public isReadonly(): boolean {
73+
return false;
74+
}
75+
7276
public dispose(): void {
7377
this._onDispose.fire();
7478
}

src/vs/workbench/services/bulkEdit/electron-browser/bulkEditService.ts

+3
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ class BulkEditModel implements IDisposable {
180180
if (!model || !model.textEditorModel) {
181181
throw new Error(`Cannot load file ${key}`);
182182
}
183+
if (model.isReadonly) {
184+
throw new Error(localize('editorIsReadonly', "Cannot edit a read-only editor."));
185+
}
183186

184187
let task: ModelEditTask;
185188
if (this._editor && this._editor.getModel().uri.toString() === model.textEditorModel.uri.toString()) {

src/vs/workbench/services/textfile/common/textfiles.ts

-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport
254254

255255
isResolved(): boolean;
256256

257-
isReadonly(): boolean;
258-
259257
isDisposed(): boolean;
260258
}
261259

0 commit comments

Comments
 (0)