Skip to content
Draft
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
18 changes: 11 additions & 7 deletions src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,23 @@ export class ViewOverlayWidgets extends ViewPart {
}

const maxRight = (2 * this._verticalScrollbarWidth) + this._minimapWidth;
if (widgetData.preference === OverlayWidgetPositionPreference.TOP_RIGHT_CORNER || widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
if (widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
const widgetHeight = domNode.domNode.clientHeight;
domNode.setTop((this._editorHeight - widgetHeight - 2 * this._horizontalScrollbarHeight));
if (widgetData.preference === OverlayWidgetPositionPreference.TOP_RIGHT_CORNER) {
domNode.setRight(maxRight);
if (widgetData.stack !== undefined) {
domNode.setTop(stackCoordinates[OverlayWidgetPositionPreference.TOP_RIGHT_CORNER]);
stackCoordinates[OverlayWidgetPositionPreference.TOP_RIGHT_CORNER] += domNode.domNode.clientHeight + 4 /* gap */;
} else {
domNode.setTop(0);
}
} else if (widgetData.preference === OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER) {
const widgetHeight = domNode.domNode.clientHeight;

domNode.setRight(maxRight);
if (widgetData.stack !== undefined) {
domNode.setTop(stackCoordinates[widgetData.preference]);
stackCoordinates[widgetData.preference] += domNode.domNode.clientWidth;
domNode.setTop(this._editorHeight - stackCoordinates[OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER] - widgetHeight - 2 * this._horizontalScrollbarHeight);
stackCoordinates[OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER] += widgetHeight + 4 /* gap */;
Comment thread
lszomoru marked this conversation as resolved.
} else {
domNode.setRight(maxRight);
domNode.setTop((this._editorHeight - widgetHeight - 2 * this._horizontalScrollbarHeight));
}
} else if (widgetData.preference === OverlayWidgetPositionPreference.TOP_CENTER) {
domNode.domNode.style.right = '50%';
Expand Down
7 changes: 4 additions & 3 deletions src/vs/editor/contrib/floatingMenu/browser/floatingMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { HiddenItemStrategy, MenuWorkbenchToolBar } from '../../../../platform/a
import { IMenuService, MenuId, MenuItemAction } from '../../../../platform/actions/common/actions.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { ICodeEditor, OverlayWidgetPositionPreference } from '../../../browser/editorBrowser.js';
import { ICodeEditor, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from '../../../browser/editorBrowser.js';
import { observableCodeEditor } from '../../../browser/observableCodeEditor.js';
import { IEditorContribution } from '../../../common/editorCommon.js';

Expand Down Expand Up @@ -86,8 +86,9 @@ export class FloatingEditorToolbar extends Disposable implements IEditorContribu
domNode: container.root,
minContentWidthInPx: constObservable(0),
position: constObservable({
preference: OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER
})
preference: OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER,
stackOrdinal: 2
} satisfies IOverlayWidgetPosition)
}));
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import './media/chatEditingEditorOverlay.css';
import { combinedDisposable, Disposable, DisposableMap, DisposableStore, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';
import { autorun, derived, derivedOpts, IObservable, observableFromEvent, observableFromEventOpts, observableSignalFromEvent, observableValue, transaction } from '../../../../../base/common/observable.js';
import { combinedDisposable, Disposable, DisposableMap, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';
import { autorun, constObservable, derived, derivedOpts, IObservable, observableFromEvent, observableFromEventOpts, observableSignalFromEvent, observableValue, transaction } from '../../../../../base/common/observable.js';
import { HiddenItemStrategy, MenuWorkbenchToolBar } from '../../../../../platform/actions/browser/toolbar.js';
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
import { IChatEditingService, IChatEditingSession, IModifiedFileEntry, ModifiedFileEntryState } from '../../common/editing/chatEditingService.js';
Expand All @@ -23,7 +23,7 @@ import { EditorGroupView } from '../../../../browser/parts/editor/editorGroupVie
import { Event } from '../../../../../base/common/event.js';
import { ServiceCollection } from '../../../../../platform/instantiation/common/serviceCollection.js';
import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
import { EditorResourceAccessor, SideBySideEditor } from '../../../../common/editor.js';
import { EditorResourceAccessor, IEditorPane, SideBySideEditor } from '../../../../common/editor.js';
import { IInlineChatSessionService } from '../../../inlineChat/browser/inlineChatSessionService.js';
import { isEqual } from '../../../../../base/common/resources.js';
import { ObservableEditorSession } from './chatEditingEditorContextKeys.js';
Expand All @@ -33,6 +33,8 @@ import { ThemeIcon } from '../../../../../base/common/themables.js';
import * as arrays from '../../../../../base/common/arrays.js';
import { renderAsPlaintext } from '../../../../../base/browser/markdownRenderer.js';
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
import { observableCodeEditor } from '../../../../../editor/browser/observableCodeEditor.js';
import { IOverlayWidgetPosition, isCodeEditor, OverlayWidgetPositionPreference } from '../../../../../editor/browser/editorBrowser.js';

class ChatEditorOverlayWidget extends Disposable {

Expand Down Expand Up @@ -317,26 +319,53 @@ class ChatEditingOverlayController {
) {

this._domNode.classList.add('chat-editing-editor-overlay');
this._domNode.style.position = 'absolute';
this._domNode.style.bottom = `24px`;
this._domNode.style.right = `24px`;
this._domNode.style.zIndex = `100`;

const widget = instaService.createInstance(ChatEditorOverlayWidget, group);
this._domNode.appendChild(widget.getDomNode());
this._store.add(toDisposable(() => this._domNode.remove()));
this._store.add(widget);

const show = () => {
if (!container.contains(this._domNode)) {
container.appendChild(this._domNode);
}
};
let overlayWidget: IDisposable | undefined = undefined;

let hide = () => { };

const show = (editor: IEditorPane) => {
const ctrl = editor.getControl();

if (isCodeEditor(ctrl)) {
// code editor special case
if (!overlayWidget) {
const editorObs = observableCodeEditor(ctrl);
overlayWidget = editorObs.createOverlayWidget({
allowEditorOverflow: false,
domNode: this._domNode,
minContentWidthInPx: constObservable(0),
position: constObservable({
preference: OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER,
stackOrdinal: 1
} satisfies IOverlayWidgetPosition)
});

hide = () => {
if (overlayWidget) {
widget.hide();
overlayWidget.dispose();
overlayWidget = undefined;
}
};
}
} else {
// generic positioning
if (!container.contains(this._domNode)) {
container.appendChild(this._domNode);
}

const hide = () => {
if (container.contains(this._domNode)) {
widget.hide();
this._domNode.remove();
hide = () => {
if (container.contains(this._domNode)) {
widget.hide();
this._domNode.remove();
}
};
}
};

Expand Down Expand Up @@ -410,7 +439,7 @@ class ChatEditingOverlayController {
);

widget.show(session, entry, { entryIndex, changeIndex });
show();
show(editorPane);

} else {
// nothing
Expand Down
Loading