提交 06bf8e65 编写于 作者: B Benjamin Pasero

editors - update readonly options when file providers change (fix #110854)

上级 990ca74d
......@@ -31,6 +31,7 @@ import { EditorActivation, IEditorOptions } from 'vs/platform/editor/common/edit
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { isEqual } from 'vs/base/common/resources';
import { multibyteAwareBtoa } from 'vs/base/browser/dom';
import { IFileService } from 'vs/platform/files/common/files';
/**
* The text editor that leverages the diff text editor for the editing experience.
......@@ -61,9 +62,28 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditorPan
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IEditorService editorService: IEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupsService editorGroupService: IEditorGroupsService
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IFileService private readonly fileService: IFileService
) {
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorService, editorGroupService);
// Listen to file system provider changes
this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidFileSystemProviderChange(e.scheme)));
this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidFileSystemProviderChange(e.scheme)));
}
private onDidFileSystemProviderChange(scheme: string): void {
const control = this.getControl();
const input = this.input;
if (control && input instanceof DiffEditorInput) {
if (input.originalInput.resource?.scheme === scheme || input.modifiedInput.resource?.scheme === scheme) {
control.updateOptions({
readOnly: input.modifiedInput.isReadonly(),
originalEditable: !input.originalInput.isReadonly()
});
}
}
}
protected onWillCloseEditorInGroup(editor: IEditorInput): void {
......
......@@ -60,6 +60,10 @@ export class TextFileEditor extends BaseTextEditor {
// Move view state for moved files
this._register(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e)));
// Listen to file system provider changes
this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidFileSystemProviderChange(e.scheme)));
this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidFileSystemProviderChange(e.scheme)));
}
private onDidFilesChange(e: FileChangesEvent): void {
......@@ -75,6 +79,14 @@ export class TextFileEditor extends BaseTextEditor {
}
}
private onDidFileSystemProviderChange(scheme: string): void {
const control = this.getControl();
const input = this.input;
if (control && input?.resource.scheme === scheme) {
control.updateOptions({ readOnly: input.isReadonly() });
}
}
protected onWillCloseEditorInGroup(editor: IEditorInput): void {
// React to editors closing to preserve or clear view state. This needs to happen
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册