Skip to content

Commit ed32bc2

Browse files
author
Benjamin Pasero
committed
status - do not show encoding picker so early
1 parent d961010 commit ed32bc2

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { ConfigurationChangedEvent, IEditorOptions, EditorOption } from 'vs/edit
3939
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
4040
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
4141
import { deepClone } from 'vs/base/common/objects';
42-
import { ICodeEditor, isCodeEditor, isDiffEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
42+
import { ICodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
4343
import { Schemas } from 'vs/base/common/network';
4444
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
4545
import { IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
@@ -570,7 +570,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
570570
this.onSelectionChange(activeCodeEditor);
571571
this.onModeChange(activeCodeEditor);
572572
this.onEOLChange(activeCodeEditor);
573-
this.onEncodingChange(activeControl);
573+
this.onEncodingChange(activeControl, activeCodeEditor);
574574
this.onIndentationChange(activeCodeEditor);
575575
this.onMetadataChange(activeControl);
576576

@@ -770,16 +770,18 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
770770
this.updateState(info);
771771
}
772772

773-
private onEncodingChange(e?: IBaseEditor): void {
774-
if (e && !this.isActiveEditor(e)) {
773+
private onEncodingChange(editor: IBaseEditor | undefined, editorWidget: ICodeEditor | undefined): void {
774+
if (editor && !this.isActiveEditor(editor)) {
775775
return;
776776
}
777777

778778
const info: StateDelta = { encoding: undefined };
779779

780-
// We only support text based editors
781-
if (e && (isCodeEditor(e.getControl()) || isDiffEditor(e.getControl()))) {
782-
const encodingSupport: IEncodingSupport | null = e.input ? toEditorWithEncodingSupport(e.input) : null;
780+
// We only support text based editors that have a model associated
781+
// This ensures we do not show the encoding picker while an editor
782+
// is still loading.
783+
if (editor && editorWidget && editorWidget.hasModel()) {
784+
const encodingSupport: IEncodingSupport | null = editor.input ? toEditorWithEncodingSupport(editor.input) : null;
783785
if (encodingSupport) {
784786
const rawEncoding = encodingSupport.getEncoding();
785787
const encodingInfo = typeof rawEncoding === 'string' ? SUPPORTED_ENCODINGS[rawEncoding] : undefined;
@@ -799,7 +801,9 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
799801
if (activeControl) {
800802
const activeResource = toResource(activeControl.input, { supportSideBySide: SideBySideEditor.MASTER });
801803
if (activeResource && isEqual(activeResource, resource)) {
802-
return this.onEncodingChange(activeControl); // only update if the encoding changed for the active resource
804+
const activeCodeEditor = withNullAsUndefined(getCodeEditor(activeControl.getControl()));
805+
806+
return this.onEncodingChange(activeControl, activeCodeEditor); // only update if the encoding changed for the active resource
803807
}
804808
}
805809
}

0 commit comments

Comments
 (0)