mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
Update breadcrumbs when workspace folders update (#154616)
This commit is contained in:
parent
955991d7f7
commit
ed81603169
|
@ -114,6 +114,7 @@ export class ResourceLabels extends Disposable {
|
|||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IModelService private readonly modelService: IModelService,
|
||||
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
|
||||
@ILanguageService private readonly languageService: ILanguageService,
|
||||
@IDecorationsService private readonly decorationsService: IDecorationsService,
|
||||
@IThemeService private readonly themeService: IThemeService,
|
||||
|
@ -153,6 +154,11 @@ export class ResourceLabels extends Disposable {
|
|||
this.widgets.forEach(widget => widget.notifyModelAdded(model));
|
||||
}));
|
||||
|
||||
// notify when workspace folders changes
|
||||
this._register(this.workspaceService.onDidChangeWorkspaceFolders(() => {
|
||||
this.widgets.forEach(widget => widget.notifyWorkspaceFoldersChange());
|
||||
}));
|
||||
|
||||
// notify when file decoration changes
|
||||
this._register(this.decorationsService.onDidChangeDecorations(e => {
|
||||
let notifyDidChangeDecorations = false;
|
||||
|
@ -250,13 +256,14 @@ export class ResourceLabel extends ResourceLabels {
|
|||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IWorkspaceContextService workspaceService: IWorkspaceContextService,
|
||||
@ILanguageService languageService: ILanguageService,
|
||||
@IDecorationsService decorationsService: IDecorationsService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@ILabelService labelService: ILabelService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(DEFAULT_LABELS_CONTAINER, instantiationService, configurationService, modelService, languageService, decorationsService, themeService, labelService, textFileService);
|
||||
super(DEFAULT_LABELS_CONTAINER, instantiationService, configurationService, modelService, workspaceService, languageService, decorationsService, themeService, labelService, textFileService);
|
||||
|
||||
this.label = this._register(this.create(container, options));
|
||||
}
|
||||
|
@ -279,6 +286,7 @@ class ResourceLabelWidget extends IconLabel {
|
|||
private computedIconClasses: string[] | undefined = undefined;
|
||||
private computedLanguageId: string | undefined = undefined;
|
||||
private computedPathLabel: string | undefined = undefined;
|
||||
private computedWorkspaceFolderLabel: string | undefined = undefined;
|
||||
|
||||
private needsRedraw: Redraw | undefined = undefined;
|
||||
private isHidden: boolean = false;
|
||||
|
@ -374,6 +382,15 @@ class ResourceLabelWidget extends IconLabel {
|
|||
}
|
||||
}
|
||||
|
||||
notifyWorkspaceFoldersChange(): void {
|
||||
if (typeof this.computedWorkspaceFolderLabel === 'string') {
|
||||
const resource = toResource(this.label);
|
||||
if (URI.isUri(resource) && this.label?.name === this.computedWorkspaceFolderLabel) {
|
||||
this.setFile(resource, this.options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setFile(resource: URI, options?: IFileLabelOptions): void {
|
||||
const hideLabel = options?.hideLabel;
|
||||
let name: string | undefined;
|
||||
|
@ -382,6 +399,7 @@ class ResourceLabelWidget extends IconLabel {
|
|||
const workspaceFolder = this.contextService.getWorkspaceFolder(resource);
|
||||
if (workspaceFolder) {
|
||||
name = workspaceFolder.name;
|
||||
this.computedWorkspaceFolderLabel = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,5 +620,6 @@ class ResourceLabelWidget extends IconLabel {
|
|||
this.computedLanguageId = undefined;
|
||||
this.computedIconClasses = undefined;
|
||||
this.computedPathLabel = undefined;
|
||||
this.computedWorkspaceFolderLabel = undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,10 +280,10 @@ export class BreadcrumbsControl {
|
|||
this._editorGroup.activeEditorPane
|
||||
);
|
||||
|
||||
this.domNode.classList.toggle('relative-path', model.isRelative());
|
||||
this.domNode.classList.toggle('backslash-path', this._labelService.getSeparator(uri.scheme, uri.authority) === '\\');
|
||||
|
||||
const updateBreadcrumbs = () => {
|
||||
this.domNode.classList.toggle('relative-path', model.isRelative());
|
||||
const showIcons = this._cfShowIcons.getValue();
|
||||
const options: IBreadcrumbsControlOptions = {
|
||||
...this._options,
|
||||
|
|
|
@ -37,7 +37,7 @@ export class OutlineElement2 {
|
|||
export class BreadcrumbsModel {
|
||||
|
||||
private readonly _disposables = new DisposableStore();
|
||||
private readonly _fileInfo: FileInfo;
|
||||
private _fileInfo: FileInfo;
|
||||
|
||||
private readonly _cfgFilePath: BreadcrumbsConfig<'on' | 'off' | 'last'>;
|
||||
private readonly _cfgSymbolPath: BreadcrumbsConfig<'on' | 'off' | 'last'>;
|
||||
|
@ -60,6 +60,7 @@ export class BreadcrumbsModel {
|
|||
|
||||
this._disposables.add(this._cfgFilePath.onDidChange(_ => this._onDidUpdate.fire(this)));
|
||||
this._disposables.add(this._cfgSymbolPath.onDidChange(_ => this._onDidUpdate.fire(this)));
|
||||
this._workspaceService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspaceFolders, this, this._disposables);
|
||||
this._fileInfo = this._initFilePathInfo(resource);
|
||||
|
||||
if (editor) {
|
||||
|
@ -146,6 +147,11 @@ export class BreadcrumbsModel {
|
|||
return info;
|
||||
}
|
||||
|
||||
private _onDidChangeWorkspaceFolders() {
|
||||
this._fileInfo = this._initFilePathInfo(this.resource);
|
||||
this._onDidUpdate.fire(this);
|
||||
}
|
||||
|
||||
private _bindToEditor(editor: IEditorPane): void {
|
||||
const newCts = new CancellationTokenSource();
|
||||
this._currentOutline.clear();
|
||||
|
|
Loading…
Reference in a new issue