Skip to content
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

precedence for isReadonly() for #181708 #181955

Merged
merged 2 commits into from May 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -140,20 +140,24 @@ export class FilesConfigurationService extends Disposable implements IFilesConfi
}

isReadonly(resource: URI, stat?: IFileStatWithMetadata): boolean {

// session override always wins over the others
const sessionReadonlyOverride = this.sessionReadonlyOverrides.get(resource);
if (typeof sessionReadonlyOverride === 'boolean') {
return sessionReadonlyOverride; // session override always wins
return sessionReadonlyOverride;
}

if (this.uriIdentityService.extUri.isEqualOrParent(resource, this.environmentService.userRoamingDataHome)) {
return false; // never turn configuration folder readonly
}

if (this.configuredReadonlyFromPermissions && stat?.locked) {
return true; // leverage file permissions if configured as such
// configured glob patterns win over stat information
if (this.readonlyIncludeMatcher.value.matches(resource)) {
return !this.readonlyExcludeMatcher.value.matches(resource);
}

return this.readonlyIncludeMatcher.value.matches(resource) && !this.readonlyExcludeMatcher.value.matches(resource);
// finally check for stat information
return (this.configuredReadonlyFromPermissions && stat?.locked) ?? stat?.readonly ?? false;
}

async updateReadonly(resource: URI, readonly: true | false | 'toggle' | 'reset'): Promise<void> {
Expand Down
Expand Up @@ -1160,8 +1160,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}

override isReadonly(): boolean {
return this.lastResolvedFileStat?.readonly ||
this.fileService.hasCapability(this.resource, FileSystemProviderCapabilities.Readonly) ||
return this.fileService.hasCapability(this.resource, FileSystemProviderCapabilities.Readonly) ||
this.filesConfigurationService.isReadonly(this.resource, this.lastResolvedFileStat);
}

Expand Down
Expand Up @@ -1245,8 +1245,7 @@ export class StoredFileWorkingCopy<M extends IStoredFileWorkingCopyModel> extend
//#region Utilities

isReadonly(): boolean {
return this.lastResolvedFileStat?.readonly ||
this.fileService.hasCapability(this.resource, FileSystemProviderCapabilities.Readonly) ||
return this.fileService.hasCapability(this.resource, FileSystemProviderCapabilities.Readonly) ||
this.filesConfigurationService.isReadonly(this.resource, this.lastResolvedFileStat);
}

Expand Down