Skip to content

Commit

Permalink
feat: support overwrite when editor save (#2846)
Browse files Browse the repository at this point in the history
  • Loading branch information
winjo authored Jun 28, 2023
1 parent 056e778 commit ece937c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,15 @@ export class EditorDocumentModel extends Disposable implements IEditorDocumentMo
}
return false;
} else if (res.state === SaveTaskResponseState.DIFF) {
const diffAndSave = localize('doc.saveError.diffAndSave');
const overwrite = localize('doc.saveError.overwrite');
this.messageService
.error(formatLocalize('doc.saveError.diff', this.uri.toString()), [localize('doc.saveError.diffAndSave')])
.error(formatLocalize('doc.saveError.diff', this.uri.toString()), [diffAndSave, overwrite])
.then((res) => {
if (res) {
if (res === diffAndSave) {
this.compareAndSave();
} else if (res === overwrite) {
this.save(true);
}
});
this.logger.error('The file cannot be saved, the version is inconsistent with the disk');
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/common/en-US.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ export const localizationBundle = {
'doc.saveError.failed': 'File Saving Failed. Reason: ',
'doc.saveError.diff': '{0} cannot be saved because it has been modified by other editors.',
'doc.saveError.diffAndSave': 'Compare...',
'doc.saveError.overwrite': 'Overwrite',
'editor.compareAndSave.title': '{0} (on Disk) <=> {1} (Editing) ',

'workspace.openDirectory': 'Open Directory',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/common/zh-CN.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ export const localizationBundle = {
'doc.saveError.failed': '文件保存失败, 原因:',
'doc.saveError.diff': '{0} 已经在磁盘上被修改,不能保存',
'doc.saveError.diffAndSave': '进行比较',
'doc.saveError.overwrite': '覆盖',
'editor.compareAndSave.title': '{0} (在磁盘上) <=> {1} (编辑中) ',

'outline.title': '大纲',
Expand Down

0 comments on commit ece937c

Please sign in to comment.