Even with force write, keep the file dirty

This commit is contained in:
Raymond Zhao 2021-11-24 12:55:33 -08:00
parent a557a12ca9
commit ef9e7408e6
No known key found for this signature in database
GPG key ID: D36E5FCE46B63B58

View file

@ -181,7 +181,8 @@ export class ConfigurationEditingService {
const reference = await this.resolveModelReference(resource);
try {
const formattingOptions = this.getFormattingOptions(reference.object.textEditorModel);
if (this.uriIdentityService.extUri.isEqual(resource, this.environmentService.settingsResource)) {
const isDirty = this.textFileService.isDirty(resource);
if (!isDirty && this.uriIdentityService.extUri.isEqual(resource, this.environmentService.settingsResource)) {
await this.userConfigurationFileService.updateSettings({ path: operation.jsonPath, value: operation.value }, formattingOptions);
} else {
await this.updateConfiguration(operation, reference.object.textEditorModel, formattingOptions);
@ -204,9 +205,12 @@ export class ConfigurationEditingService {
throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION, operation.target, operation);
}
const isDirty = this.textFileService.isDirty(model.uri);
const edit = this.getEdits(operation, model.getValue(), formattingOptions)[0];
if (edit && this.applyEditsToBuffer(edit, model)) {
await this.textFileService.save(model.uri);
if (!isDirty) {
await this.textFileService.save(model.uri);
}
}
}