提交 315d3524 编写于 作者: A Ahmed Atito 提交者: Benjamin Pasero

Update status bar when opening a binary file as text (#59914)

* 🐛 - Update status bar when opening a binary file as text

* avoid timeout
上级 b65d113c
...@@ -21,7 +21,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; ...@@ -21,7 +21,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { dispose } from 'vs/base/common/lifecycle'; import { dispose } from 'vs/base/common/lifecycle';
export interface IOpenCallbacks { export interface IOpenCallbacks {
openInternal: (input: EditorInput, options: EditorOptions) => void; openInternal: (input: EditorInput, options: EditorOptions) => Thenable<void>;
openExternal: (uri: URI) => void; openExternal: (uri: URI) => void;
} }
...@@ -33,6 +33,9 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -33,6 +33,9 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
private readonly _onMetadataChanged: Emitter<void> = this._register(new Emitter<void>()); private readonly _onMetadataChanged: Emitter<void> = this._register(new Emitter<void>());
get onMetadataChanged(): Event<void> { return this._onMetadataChanged.event; } get onMetadataChanged(): Event<void> { return this._onMetadataChanged.event; }
private readonly _onDidOpenInPlace: Emitter<void> = this._register(new Emitter<void>());
get onDidOpenInPlace(): Event<void> { return this._onDidOpenInPlace.event; }
private callbacks: IOpenCallbacks; private callbacks: IOpenCallbacks;
private metadata: string; private metadata: string;
private binaryContainer: HTMLElement; private binaryContainer: HTMLElement;
...@@ -88,7 +91,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -88,7 +91,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
this._fileService, this._fileService,
this.binaryContainer, this.binaryContainer,
this.scrollbar, this.scrollbar,
resource => this.callbacks.openInternal(input, options), resource => this.handleOpenInternalCallback(input, options),
resource => this.callbacks.openExternal(resource), resource => this.callbacks.openExternal(resource),
meta => this.handleMetadataChanged(meta) meta => this.handleMetadataChanged(meta)
); );
...@@ -98,6 +101,14 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -98,6 +101,14 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
}); });
} }
private handleOpenInternalCallback(input: EditorInput, options: EditorOptions) {
this.callbacks.openInternal(input, options).then(() => {
// Signal to listeners that the binary editor has been opened in-place
this._onDidOpenInPlace.fire();
});
}
private handleMetadataChanged(meta: string): void { private handleMetadataChanged(meta: string): void {
this.metadata = meta; this.metadata = meta;
......
...@@ -619,6 +619,10 @@ export class EditorStatus implements IStatusbarItem { ...@@ -619,6 +619,10 @@ export class EditorStatus implements IStatusbarItem {
this.activeEditorListeners.push(editor.onMetadataChanged(metadata => { this.activeEditorListeners.push(editor.onMetadataChanged(metadata => {
this.onMetadataChange(activeControl); this.onMetadataChange(activeControl);
})); }));
this.activeEditorListeners.push(editor.onDidOpenInPlace(() => {
this.updateStatusBar();
}));
}); });
} }
} }
......
...@@ -41,11 +41,14 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { ...@@ -41,11 +41,14 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
); );
} }
private openInternal(input: EditorInput, options: EditorOptions): void { private openInternal(input: EditorInput, options: EditorOptions): Thenable<void> {
if (input instanceof FileEditorInput) { if (input instanceof FileEditorInput) {
input.setForceOpenAsText(); input.setForceOpenAsText();
this.editorService.openEditor(input, options, this.group);
return this.editorService.openEditor(input, options, this.group).then(() => void 0);
} }
return Promise.resolve();
} }
private openExternal(resource: URI): void { private openExternal(resource: URI): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册