Skip to content

do not attempt edit operation for read-only editors #56824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vs/editor/common/services/resolverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ export interface ITextEditorModel extends IEditorModel {
* Provides access to the underlying `ITextModel`.
*/
textEditorModel: ITextModel;

isReadonly(): boolean;
}
4 changes: 4 additions & 0 deletions src/vs/editor/standalone/browser/simpleServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class SimpleModel implements ITextEditorModel {
return this.model;
}

public isReadonly(): boolean {
return false;
}

public dispose(): void {
this._onDispose.fire();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class BulkEditModel implements IDisposable {
if (!model || !model.textEditorModel) {
throw new Error(`Cannot load file ${key}`);
}
if (model.isReadonly) {
throw new Error(localize('editorIsReadonly', "Cannot edit a read-only editor."));
}

let task: ModelEditTask;
if (this._editor && this._editor.getModel().uri.toString() === model.textEditorModel.uri.toString()) {
Expand Down
2 changes: 0 additions & 2 deletions src/vs/workbench/services/textfile/common/textfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport

isResolved(): boolean;

isReadonly(): boolean;

isDisposed(): boolean;
}

Expand Down