Enable dragging of editor from breadcrumbs in single tabs (#236571)
drag editor from single tab breadcrumbspull/236574/head
parent
011e8ec6df
commit
22959031c0
|
@ -25,7 +25,7 @@ import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/c
|
|||
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
|
||||
import { IContextViewService } from '../../../../platform/contextview/browser/contextView.js';
|
||||
import { fillInSymbolsDragData } from '../../../../platform/dnd/browser/dnd.js';
|
||||
import { fillInSymbolsDragData, LocalSelectionTransfer } from '../../../../platform/dnd/browser/dnd.js';
|
||||
import { FileKind, IFileService, IFileStat } from '../../../../platform/files/common/files.js';
|
||||
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { InstantiationService } from '../../../../platform/instantiation/common/instantiationService.js';
|
||||
|
@ -39,7 +39,7 @@ import { EditorResourceAccessor, IEditorPartOptions, SideBySideEditor } from '..
|
|||
import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js';
|
||||
import { ACTIVE_GROUP, ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP, SIDE_GROUP_TYPE } from '../../../services/editor/common/editorService.js';
|
||||
import { IOutline } from '../../../services/outline/browser/outline.js';
|
||||
import { fillEditorsDragData } from '../../dnd.js';
|
||||
import { DraggedEditorIdentifier, fillEditorsDragData } from '../../dnd.js';
|
||||
import { DEFAULT_LABELS_CONTAINER, ResourceLabels } from '../../labels.js';
|
||||
import { BreadcrumbsConfig, IBreadcrumbsService } from './breadcrumbs.js';
|
||||
import { BreadcrumbsModel, FileElement, OutlineElement2 } from './breadcrumbsModel.js';
|
||||
|
@ -105,7 +105,7 @@ class OutlineItem extends BreadcrumbsItem {
|
|||
this._disposables.add(toDisposable(() => { renderer.disposeTemplate(template); }));
|
||||
|
||||
if (element instanceof OutlineElement && outline.uri) {
|
||||
this._disposables.add(this._instantiationService.invokeFunction(accessor => createBreadcrumbDndObserver(accessor, container, element.symbol.name, { symbol: element.symbol, uri: outline.uri! })));
|
||||
this._disposables.add(this._instantiationService.invokeFunction(accessor => createBreadcrumbDndObserver(accessor, container, element.symbol.name, { symbol: element.symbol, uri: outline.uri! }, this.model, this.options.dragEditor)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +151,12 @@ class FileItem extends BreadcrumbsItem {
|
|||
container.classList.add(FileKind[this.element.kind].toLowerCase());
|
||||
this._disposables.add(label);
|
||||
|
||||
this._disposables.add(this._instantiationService.invokeFunction(accessor => createBreadcrumbDndObserver(accessor, container, basename(this.element.uri), this.element.uri)));
|
||||
this._disposables.add(this._instantiationService.invokeFunction(accessor => createBreadcrumbDndObserver(accessor, container, basename(this.element.uri), this.element.uri, this.model, this.options.dragEditor)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createBreadcrumbDndObserver(accessor: ServicesAccessor, container: HTMLElement, label: string, item: URI | { symbol: DocumentSymbol; uri: URI }): IDisposable {
|
||||
function createBreadcrumbDndObserver(accessor: ServicesAccessor, container: HTMLElement, label: string, item: URI | { symbol: DocumentSymbol; uri: URI }, model: BreadcrumbsModel, dragEditor: boolean): IDisposable {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
|
||||
container.draggable = true;
|
||||
|
@ -183,6 +183,11 @@ function createBreadcrumbDndObserver(accessor: ServicesAccessor, container: HTML
|
|||
kind: item.symbol.kind
|
||||
}], event);
|
||||
}
|
||||
|
||||
if (dragEditor && model.editor && model.editor?.input) {
|
||||
const editorTransfer = LocalSelectionTransfer.getInstance<DraggedEditorIdentifier>();
|
||||
editorTransfer.setData([new DraggedEditorIdentifier({ editor: model.editor.input, groupId: model.editor.group.id })], DraggedEditorIdentifier.prototype);
|
||||
}
|
||||
});
|
||||
|
||||
// Create drag image and remove when dropped
|
||||
|
@ -209,6 +214,7 @@ export interface IBreadcrumbsControlOptions {
|
|||
readonly showSymbolIcons: boolean;
|
||||
readonly showDecorationColors: boolean;
|
||||
readonly showPlaceholder: boolean;
|
||||
readonly dragEditor: boolean;
|
||||
readonly widgetStyles?: IBreadcrumbsWidgetStyles;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ export class BreadcrumbsModel {
|
|||
|
||||
constructor(
|
||||
readonly resource: URI,
|
||||
editor: IEditorPane | undefined,
|
||||
readonly editor: IEditorPane | undefined,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkspaceContextService private readonly _workspaceService: IWorkspaceContextService,
|
||||
@IOutlineService private readonly _outlineService: IOutlineService,
|
||||
|
|
|
@ -90,7 +90,8 @@ export class EditorTitleControl extends Themable {
|
|||
showFileIcons: true,
|
||||
showSymbolIcons: true,
|
||||
showDecorationColors: false,
|
||||
showPlaceholder: true
|
||||
showPlaceholder: true,
|
||||
dragEditor: false,
|
||||
}));
|
||||
|
||||
// Breadcrumbs enablement & visibility change have an impact on layout
|
||||
|
|
|
@ -60,7 +60,8 @@ export class SingleEditorTabsControl extends EditorTabsControl {
|
|||
showSymbolIcons: true,
|
||||
showDecorationColors: false,
|
||||
widgetStyles: { ...defaultBreadcrumbsWidgetStyles, breadcrumbsBackground: Color.transparent.toString() },
|
||||
showPlaceholder: false
|
||||
showPlaceholder: false,
|
||||
dragEditor: true,
|
||||
}));
|
||||
this._register(this.breadcrumbsControlFactory.onDidEnablementChange(() => this.handleBreadcrumbsEnablementChange()));
|
||||
titleContainer.classList.toggle('breadcrumbs', Boolean(this.breadcrumbsControl));
|
||||
|
|
Loading…
Reference in New Issue