editors - restore offset for drop ops as it was

This commit is contained in:
Benjamin Pasero 2020-09-22 09:05:22 +02:00
parent 4ad1655304
commit 7d1ccd3eb6
7 changed files with 39 additions and 15 deletions

View file

@ -108,6 +108,22 @@ export interface IEditorGroupsAccessor {
arrangeGroups(arrangement: GroupsArrangement, target?: IEditorGroupView | GroupIdentifier): void;
}
export interface IEditorGroupTitleDimensions {
/**
* The overall height of the editor group title control.
*/
height: number;
/**
* The height offset to e.g. use when drawing drop overlays.
* This number may be smaller than `height` if the title control
* decides to have an `offset` that is within the title area
* (e.g. when breadcrumbs are enabled).
*/
offset: number;
}
export interface IEditorGroupView extends IDisposable, ISerializableView, IEditorGroup {
readonly onDidFocus: Event<void>;
@ -120,7 +136,7 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
readonly group: EditorGroup;
readonly whenRestored: Promise<void>;
readonly preferredTitleHeight: number;
readonly titleDimensions: IEditorGroupTitleDimensions;
readonly isEmpty: boolean;
readonly isMinimized: boolean;

View file

@ -503,7 +503,7 @@ class DropOverlay extends Themable {
// With tabs and opened editors: use the area below tabs as drop target
if (!this.groupView.isEmpty && this.accessor.partOptions.showTabs) {
return this.groupView.preferredTitleHeight;
return this.groupView.titleDimensions.offset;
}
// Without tabs or empty group: use entire editor area as drop target

View file

@ -30,7 +30,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { RunOnceWorker } from 'vs/base/common/async';
import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch';
import { TitleControl } from 'vs/workbench/browser/parts/editor/titleControl';
import { IEditorGroupsAccessor, IEditorGroupView, getActiveTextEditorOptions, IEditorOpeningEvent, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupsAccessor, IEditorGroupView, getActiveTextEditorOptions, IEditorOpeningEvent, EditorServiceImpl, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ActionRunner, IAction, Action } from 'vs/base/common/actions';
@ -717,8 +717,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
return this._group.count === 0;
}
get preferredTitleHeight(): number {
return this.titleAreaControl.getPreferredHeight();
get titleDimensions(): IEditorGroupTitleDimensions {
return this.titleAreaControl.getDimensions();
}
get isMinimized(): boolean {
@ -1699,7 +1699,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this.dimension = new Dimension(width, height);
// Ensure editor container gets height as CSS depending on the preferred height of the title control
const titleHeight = this.preferredTitleHeight;
const titleHeight = this.titleDimensions.height;
const editorHeight = Math.max(0, height - titleHeight);
this.editorContainer.style.height = `${editorHeight}px`;

View file

@ -14,6 +14,7 @@ import { IAction } from 'vs/base/common/actions';
import { CLOSE_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
import { Color } from 'vs/base/common/color';
import { withNullAsUndefined, assertIsDefined, assertAllDefined } from 'vs/base/common/types';
import { IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
interface IRenderedEditorLabel {
editor?: IEditorInput;
@ -315,8 +316,11 @@ export class NoTabsTitleControl extends TitleControl {
return { primaryEditorActions: editorActions.primary.filter(action => action.id === CLOSE_EDITOR_COMMAND_ID), secondaryEditorActions: [] };
}
getPreferredHeight(): number {
return NoTabsTitleControl.HEIGHT;
getDimensions(): IEditorGroupTitleDimensions {
return {
height: NoTabsTitleControl.HEIGHT,
offset: 0
};
}
layout(dimension: Dimension): void {

View file

@ -34,7 +34,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { MergeGroupMode, IMergeGroupOptions, GroupsArrangement, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { addDisposableListener, EventType, EventHelper, Dimension, scheduleAtNextAnimationFrame, findParentWithClass, clearNode } from 'vs/base/browser/dom';
import { localize } from 'vs/nls';
import { IEditorGroupsAccessor, IEditorGroupView, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupsAccessor, IEditorGroupView, EditorServiceImpl, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
import { CloseOneEditorAction, UnpinEditorAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { BreadcrumbsControl } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
@ -1222,13 +1222,16 @@ export class TabsTitleControl extends TitleControl {
return hasModifiedBorderColor;
}
getPreferredHeight(): number {
getDimensions(): IEditorGroupTitleDimensions {
let height = TabsTitleControl.TAB_HEIGHT;
if (this.breadcrumbsControl && !this.breadcrumbsControl.isHidden()) {
height += BreadcrumbsControl.HEIGHT;
}
return height;
return {
height,
offset: TabsTitleControl.TAB_HEIGHT
};
}
layout(dimension: Dimension | undefined): void {

View file

@ -31,7 +31,7 @@ import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, fillResourceData
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs';
import { BreadcrumbsControl, IBreadcrumbsControlOptions } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
import { IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupsAccessor, IEditorGroupTitleDimensions, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { EditorCommandsContextActionRunner, IEditorCommandsContext, IEditorInput, toResource, IEditorPartOptions, SideBySideEditor, ActiveEditorPinnedContext, ActiveEditorStickyContext } from 'vs/workbench/common/editor';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@ -409,7 +409,7 @@ export abstract class TitleControl extends Themable {
abstract layout(dimension: Dimension): void;
abstract getPreferredHeight(): number;
abstract getDimensions(): IEditorGroupTitleDimensions;
dispose(): void {
dispose(this.breadcrumbsControl);

View file

@ -11,7 +11,7 @@ import { URI } from 'vs/base/common/uri';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputFactory, Extensions as EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
import { Event, Emitter } from 'vs/base/common/event';
import { IBackupFileService, IResolvedBackup } from 'vs/workbench/services/backup/common/backup';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
@ -602,7 +602,8 @@ export class TestEditorGroupView implements IEditorGroupView {
maximumWidth!: number;
minimumHeight!: number;
maximumHeight!: number;
preferredTitleHeight!: number;
titleDimensions!: IEditorGroupTitleDimensions;
isEmpty = true;
isMinimized = false;