mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-22 04:40:30 -04:00
This reverts commit 5d44b6a6a7.
This commit is contained in:
@@ -21,7 +21,7 @@ import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { getIconClasses, detectModeId } from 'vs/editor/common/services/getIconClasses';
|
||||
import { getIconClasses, getConfiguredLangId } from 'vs/editor/common/services/getIconClasses';
|
||||
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
@@ -121,16 +121,7 @@ export class ResourceLabels extends Disposable {
|
||||
return; // ignore transitions in files from no mode to specific mode because this happens each time a model is created
|
||||
}
|
||||
|
||||
this._widgets.forEach(widget => widget.notifyModelModeChanged(e.model));
|
||||
}));
|
||||
|
||||
// notify when model is added
|
||||
this._register(this.modelService.onModelAdded(model => {
|
||||
if (!model.uri) {
|
||||
return; // we need the resource to compare
|
||||
}
|
||||
|
||||
this._widgets.forEach(widget => widget.notifyModelAdded(model));
|
||||
this._widgets.forEach(widget => widget.notifyModelModeChanged(e));
|
||||
}));
|
||||
|
||||
// notify when file decoration changes
|
||||
@@ -237,7 +228,7 @@ class ResourceLabelWidget extends IconLabel {
|
||||
private label?: IResourceLabelProps;
|
||||
private options?: IResourceLabelOptions;
|
||||
private computedIconClasses?: string[];
|
||||
private lastKnownDetectedModeId?: string;
|
||||
private lastKnownConfiguredLangId?: string;
|
||||
private computedPathLabel?: string;
|
||||
|
||||
private needsRedraw?: Redraw;
|
||||
@@ -267,21 +258,13 @@ class ResourceLabelWidget extends IconLabel {
|
||||
}
|
||||
}
|
||||
|
||||
notifyModelModeChanged(model: ITextModel): void {
|
||||
this.handleModelEvent(model);
|
||||
}
|
||||
|
||||
notifyModelAdded(model: ITextModel): void {
|
||||
this.handleModelEvent(model);
|
||||
}
|
||||
|
||||
private handleModelEvent(model: ITextModel): void {
|
||||
notifyModelModeChanged(e: { model: ITextModel; oldModeId: string; }): void {
|
||||
if (!this.label || !this.label.resource) {
|
||||
return; // only update if label exists
|
||||
}
|
||||
|
||||
if (model.uri.toString() === this.label.resource.toString()) {
|
||||
if (this.lastKnownDetectedModeId !== model.getModeId()) {
|
||||
if (e.model.uri.toString() === this.label.resource.toString()) {
|
||||
if (this.lastKnownConfiguredLangId !== e.model.getLanguageIdentifier().language) {
|
||||
this.render(true); // update if the language id of the model has changed from our last known state
|
||||
}
|
||||
}
|
||||
@@ -350,7 +333,7 @@ class ResourceLabelWidget extends IconLabel {
|
||||
|
||||
setEditor(editor: IEditorInput, options?: IResourceLabelOptions): void {
|
||||
this.setResource({
|
||||
resource: toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }),
|
||||
resource: withNullAsUndefined(toResource(editor, { supportSideBySide: SideBySideEditor.MASTER })),
|
||||
name: withNullAsUndefined(editor.getName()),
|
||||
description: withNullAsUndefined(editor.getDescription())
|
||||
}, options);
|
||||
@@ -384,7 +367,7 @@ class ResourceLabelWidget extends IconLabel {
|
||||
clear(): void {
|
||||
this.label = undefined;
|
||||
this.options = undefined;
|
||||
this.lastKnownDetectedModeId = undefined;
|
||||
this.lastKnownConfiguredLangId = undefined;
|
||||
this.computedIconClasses = undefined;
|
||||
this.computedPathLabel = undefined;
|
||||
|
||||
@@ -405,10 +388,10 @@ class ResourceLabelWidget extends IconLabel {
|
||||
}
|
||||
|
||||
if (this.label) {
|
||||
const detectedModeId = this.label.resource ? withNullAsUndefined(detectModeId(this.modelService, this.modeService, this.label.resource)) : undefined;
|
||||
if (this.lastKnownDetectedModeId !== detectedModeId) {
|
||||
const configuredLangId = this.label.resource ? withNullAsUndefined(getConfiguredLangId(this.modelService, this.modeService, this.label.resource)) : undefined;
|
||||
if (this.lastKnownConfiguredLangId !== configuredLangId) {
|
||||
clearIconCache = true;
|
||||
this.lastKnownDetectedModeId = detectedModeId;
|
||||
this.lastKnownConfiguredLangId = configuredLangId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +465,7 @@ class ResourceLabelWidget extends IconLabel {
|
||||
|
||||
this.label = undefined;
|
||||
this.options = undefined;
|
||||
this.lastKnownDetectedModeId = undefined;
|
||||
this.lastKnownConfiguredLangId = undefined;
|
||||
this.computedIconClasses = undefined;
|
||||
this.computedPathLabel = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user