Skip to content

Commit 08b86c0

Browse files
authored
editors - log error from revert operations (fix microsoft#160610) (microsoft#160681)
1 parent 835ace5 commit 08b86c0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/vs/workbench/browser/parts/editor/editorActions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
3131
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
3232
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
3333
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
34+
import { ILogService } from 'vs/platform/log/common/log';
3435

3536
export class ExecuteCommandAction extends Action {
3637

@@ -483,7 +484,8 @@ export class RevertAndCloseEditorAction extends Action {
483484
constructor(
484485
id: string,
485486
label: string,
486-
@IEditorService private readonly editorService: IEditorService
487+
@IEditorService private readonly editorService: IEditorService,
488+
@ILogService private readonly logService: ILogService
487489
) {
488490
super(id, label);
489491
}
@@ -498,10 +500,13 @@ export class RevertAndCloseEditorAction extends Action {
498500
try {
499501
await this.editorService.revert({ editor, groupId: group.id });
500502
} catch (error) {
503+
this.logService.error(error);
504+
501505
// if that fails, since we are about to close the editor, we accept that
502506
// the editor cannot be reverted and instead do a soft revert that just
503507
// enables us to close the editor. With this, a user can always close a
504508
// dirty editor even when reverting fails.
509+
505510
await this.editorService.revert({ editor, groupId: group.id }, { soft: true });
506511
}
507512

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
5252
import { URI } from 'vs/base/common/uri';
5353
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
5454
import { isLinux, isNative, isWindows } from 'vs/base/common/platform';
55+
import { ILogService } from 'vs/platform/log/common/log';
5556

5657
export class EditorGroupView extends Themable implements IEditorGroupView {
5758

@@ -145,7 +146,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
145146
@IFileDialogService private readonly fileDialogService: IFileDialogService,
146147
@IEditorService private readonly editorService: EditorServiceImpl,
147148
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
148-
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
149+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
150+
@ILogService private readonly logService: ILogService
149151
) {
150152
super(themeService);
151153

@@ -1600,10 +1602,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
16001602

16011603
return editor.isDirty(); // veto if still dirty
16021604
} catch (error) {
1605+
this.logService.error(error);
1606+
16031607
// if that fails, since we are about to close the editor, we accept that
16041608
// the editor cannot be reverted and instead do a soft revert that just
16051609
// enables us to close the editor. With this, a user can always close a
16061610
// dirty editor even when reverting fails.
1611+
16071612
await editor.revert(this.id, { soft: true });
16081613

16091614
return editor.isDirty(); // veto if still dirty

0 commit comments

Comments
 (0)