Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vs/workbench/browser/parts/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
labelFormat: 'default',
splitSizing: 'auto',
splitOnDragAndDrop: true,
allowDropIntoGroup: true,
dragToOpenWindow: true,
centeredLayoutFixedWidth: false,
doubleClickTabToToggleEditorGroupSizes: 'expand',
Expand Down Expand Up @@ -142,6 +143,7 @@ function validateEditorPartOptions(options: IEditorPartOptions): IEditorPartOpti
'mouseBackForwardToNavigate': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['mouseBackForwardToNavigate']),
'restoreViewState': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['restoreViewState']),
'splitOnDragAndDrop': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['splitOnDragAndDrop']),
'allowDropIntoGroup': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['allowDropIntoGroup']),
'dragToOpenWindow': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['dragToOpenWindow']),
'centeredLayoutFixedWidth': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['centeredLayoutFixedWidth']),
'hasIcons': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['hasIcons']),
Expand Down
19 changes: 14 additions & 5 deletions src/vs/workbench/browser/parts/editor/editorDropTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IThemeService, Themable } from '../../../../platform/theme/common/theme
import { isTemporaryWorkspace, IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { CodeDataTransfers, containsDragType, Extensions as DragAndDropExtensions, IDragAndDropContributionRegistry, LocalSelectionTransfer } from '../../../../platform/dnd/browser/dnd.js';
import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, extractTreeDropData, ResourcesDropHandler } from '../../dnd.js';
import { IEditorGroupView, prepareMoveCopyEditors } from './editor.js';
import { IEditorGroupsView, IEditorGroupView, prepareMoveCopyEditors } from './editor.js';
import { EditorInputCapabilities, IEditorIdentifier, IUntypedEditorInput } from '../../../common/editor.js';
import { EDITOR_DRAG_AND_DROP_BACKGROUND, EDITOR_DROP_INTO_PROMPT_BACKGROUND, EDITOR_DROP_INTO_PROMPT_BORDER, EDITOR_DROP_INTO_PROMPT_FOREGROUND } from '../../../common/theme.js';
import { GroupDirection, IEditorDropTargetDelegate, IEditorGroup, IEditorGroupsService, IMergeGroupOptions, MergeGroupMode } from '../../../services/editor/common/editorGroupsService.js';
Expand Down Expand Up @@ -181,7 +181,7 @@ class DropOverlay extends Themable {
// Position overlay and conditionally enable or disable
// editor group splitting support based on setting and
// keymodifiers used.
let splitOnDragAndDrop = !!this.editorGroupService.partOptions.splitOnDragAndDrop;
let splitOnDragAndDrop = !!this.groupView.groupsView.partOptions.splitOnDragAndDrop;
if (this.isToggleSplitOperation(e)) {
splitOnDragAndDrop = !splitOnDragAndDrop;
}
Expand Down Expand Up @@ -316,7 +316,7 @@ class DropOverlay extends Themable {
// Optimization: if we move the last editor of an editor group
// and we are configured to close empty editor groups, we can
// rather move the entire editor group according to the direction
if (this.editorGroupService.partOptions.closeEmptyGroups && sourceGroup.count === 1 && typeof splitDirection === 'number' && !copyEditor) {
if (this.groupView.groupsView.partOptions.closeEmptyGroups && sourceGroup.count === 1 && typeof splitDirection === 'number' && !copyEditor) {
targetGroup = this.editorGroupService.moveGroup(sourceGroup, this.groupView, splitDirection);
}

Expand Down Expand Up @@ -383,7 +383,7 @@ class DropOverlay extends Themable {
}

private positionOverlay(mousePosX: number, mousePosY: number, isDraggingGroup: boolean, enableSplitting: boolean): void {
const preferSplitVertically = this.editorGroupService.partOptions.openSideBySideDirection === 'right';
const preferSplitVertically = this.groupView.groupsView.partOptions.openSideBySideDirection === 'right';

const editorControlWidth = this.groupView.element.clientWidth;
const editorControlHeight = this.groupView.element.clientHeight - this.getOverlayOffsetHeight();
Expand Down Expand Up @@ -523,7 +523,7 @@ class DropOverlay extends Themable {
private getOverlayOffsetHeight(): number {

// With tabs and opened editors: use the area below tabs as drop target
if (!this.groupView.isEmpty && this.editorGroupService.partOptions.showTabs === 'multiple') {
if (!this.groupView.isEmpty && this.groupView.groupsView.partOptions.showTabs === 'multiple') {
return this.groupView.titleHeight.offset;
}

Expand Down Expand Up @@ -571,6 +571,7 @@ export class EditorDropTarget extends Themable {
private readonly groupTransfer = LocalSelectionTransfer.getInstance<DraggedEditorGroupIdentifier>();

constructor(
private readonly groupsView: IEditorGroupsView,
private readonly container: HTMLElement,
private readonly delegate: IEditorDropTargetDelegate,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
Expand Down Expand Up @@ -620,6 +621,14 @@ export class EditorDropTarget extends Themable {
}
}

// Check if dropping into group is allowed
if (!this.groupsView.partOptions.allowDropIntoGroup) {
if (event.dataTransfer) {
event.dataTransfer.dropEffect = 'none';
}
return;
}

// Signal DND start
this.updateContainer(true);

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/editor/editorPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ export class EditorPart extends Part<IEditorPartMemento> implements IEditorPart,
createEditorDropTarget(container: unknown, delegate: IEditorDropTargetDelegate): IDisposable {
assertType(isHTMLElement(container));

return this.scopedInstantiationService.createInstance(EditorDropTarget, container, delegate);
return this.scopedInstantiationService.createInstance(EditorDropTarget, this, container, delegate);
}

//#region Part
Expand Down
10 changes: 6 additions & 4 deletions src/vs/workbench/browser/parts/editor/modalEditorPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ export class ModalEditorPart {
let height: number;

if (editorPart.maximized) {
const padding = 16; // Keep a small margin around all edges
width = Math.max(containerDimension.width - padding, 0);
height = Math.max(availableHeight - padding, 0);
const horizontalPadding = 16;
const verticalPadding = Math.max(titleBarOffset /* keep away from title bar to prevent clipping issues with WCO */, 16);
width = Math.max(containerDimension.width - horizontalPadding, 0);
height = Math.max(availableHeight - verticalPadding, 0);
} else {
const maxWidth = 1200;
const maxHeight = 800;
Expand Down Expand Up @@ -273,7 +274,8 @@ class ModalEditorPartImpl extends EditorPart implements IModalEditorPart {
tabActionCloseVisibility: editorCount > 1,
editorActionsLocation: 'default',
tabHeight: 'default',
wrapTabs: false
wrapTabs: false,
allowDropIntoGroup: false
});
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ interface IEditorPartConfiguration {
splitInGroupLayout?: 'vertical' | 'horizontal';
splitSizing?: 'auto' | 'split' | 'distribute';
splitOnDragAndDrop?: boolean;
allowDropIntoGroup?: boolean;
dragToOpenWindow?: boolean;
centeredLayoutFixedWidth?: boolean;
doubleClickTabToToggleEditorGroupSizes?: 'maximize' | 'expand' | 'off';
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/webview/browser/overlayWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IOverlayWebview, IWebview, IWebviewElement, IWebviewService, KEYBINDING
export class OverlayWebview extends Disposable implements IOverlayWebview {

private _isFirstLoad = true;
private readonly _firstLoadPendingMessages = new Set<{ readonly message: any; readonly transfer?: readonly ArrayBuffer[]; readonly resolve: (value: boolean) => void }>();
private readonly _firstLoadPendingMessages = new Set<{ readonly message: unknown; readonly transfer?: readonly ArrayBuffer[]; readonly resolve: (value: boolean) => void }>();
private readonly _webview = this._register(new MutableDisposable<IWebviewElement>());
private readonly _webviewEvents = this._register(new DisposableStore());

Expand All @@ -37,7 +37,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
private _contentOptions: WebviewContentOptions;
private _options: WebviewOptions;

private _owner: any = undefined;
private _owner: unknown = undefined;

private _windowId: number | undefined = undefined;
private get window() { return getWindowById(this._windowId, true).window; }
Expand Down Expand Up @@ -123,7 +123,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
return this._container.domNode;
}

public claim(owner: any, targetWindow: CodeWindow, scopedContextKeyService: IContextKeyService | undefined) {
public claim(owner: unknown, targetWindow: CodeWindow, scopedContextKeyService: IContextKeyService | undefined) {
if (this._isDisposed) {
return;
}
Expand Down Expand Up @@ -165,7 +165,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
}
}

public release(owner: any) {
public release(owner: unknown) {
if (this._owner !== owner) {
return;
}
Expand Down Expand Up @@ -370,7 +370,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {

public readonly intrinsicContentSize = observableValue<{ readonly width: number; readonly height: number } | undefined>('WebviewIntrinsicContentSize', undefined);

public async postMessage(message: any, transfer?: readonly ArrayBuffer[]): Promise<boolean> {
public async postMessage(message: unknown, transfer?: readonly ArrayBuffer[]): Promise<boolean> {
if (this._webview.value) {
return this._webview.value.postMessage(message, transfer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ suite('EditorGroupsService', () => {
assert.strictEqual(part.partOptions.showTabs, 'single');
assert.strictEqual(newOptions.showTabs, 'single');
assert.strictEqual(oldOptions, currentOptions);

const enforced = part.enforcePartOptions({ allowDropIntoGroup: false });
assert.strictEqual(part.partOptions.allowDropIntoGroup, false);
enforced.dispose();
assert.strictEqual(part.partOptions.allowDropIntoGroup, true);
});

test('editor basics', async function () {
Expand Down
Loading