mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Context menu of Recent Session list doesn't have show/hide actions (#280727)
* Context menu of Recent Session list doesn't have show/hide actions (fix #280556) * .
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { $, append, getWindow, setVisibility } from '../../../../base/browser/dom.js';
|
||||
import { $, addDisposableListener, append, EventHelper, EventType, getWindow, setVisibility } from '../../../../base/browser/dom.js';
|
||||
import { StandardMouseEvent } from '../../../../base/browser/mouseEvent.js';
|
||||
import { CancellationToken } from '../../../../base/common/cancellation.js';
|
||||
import { Event } from '../../../../base/common/event.js';
|
||||
import { MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
|
||||
@@ -225,6 +226,7 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
|
||||
this.viewPaneContainer.classList.add('chat-viewpane');
|
||||
|
||||
this.createControls(parent);
|
||||
this.setupContextMenu(parent);
|
||||
|
||||
this.applyModel();
|
||||
}
|
||||
@@ -369,6 +371,18 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
|
||||
this._register(autorun(reader => updateWidgetVisibility(reader)));
|
||||
}
|
||||
|
||||
private setupContextMenu(parent: HTMLElement): void {
|
||||
this._register(addDisposableListener(parent, EventType.CONTEXT_MENU, e => {
|
||||
EventHelper.stop(e, true);
|
||||
|
||||
this.contextMenuService.showContextMenu({
|
||||
menuId: MenuId.ChatWelcomeContext,
|
||||
contextKeyService: this.contextKeyService,
|
||||
getAnchor: () => new StandardMouseEvent(getWindow(parent), e)
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private async applyModel(): Promise<void> {
|
||||
const info = this.getTransferredOrPersistedSessionInfo();
|
||||
const modelRef = info.sessionId ? await this.chatService.getOrRestoreSession(LocalChatSessionUri.forSession(info.sessionId)) : undefined;
|
||||
|
||||
@@ -7,7 +7,7 @@ import './media/chat.css';
|
||||
import './media/chatAgentHover.css';
|
||||
import './media/chatViewWelcome.css';
|
||||
import * as dom from '../../../../base/browser/dom.js';
|
||||
import { IMouseWheelEvent, StandardMouseEvent } from '../../../../base/browser/mouseEvent.js';
|
||||
import { IMouseWheelEvent } from '../../../../base/browser/mouseEvent.js';
|
||||
import { Button } from '../../../../base/browser/ui/button/button.js';
|
||||
import { ITreeContextMenuEvent, ITreeElement } from '../../../../base/browser/ui/tree/tree.js';
|
||||
import { disposableTimeout, timeout } from '../../../../base/common/async.js';
|
||||
@@ -239,7 +239,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
||||
|
||||
private welcomeMessageContainer!: HTMLElement;
|
||||
private readonly welcomePart: MutableDisposable<ChatViewWelcomePart> = this._register(new MutableDisposable());
|
||||
private readonly welcomeContextMenuDisposable: MutableDisposable<IDisposable> = this._register(new MutableDisposable());
|
||||
|
||||
private readonly chatSuggestNextWidget: ChatSuggestNextWidget;
|
||||
|
||||
@@ -915,17 +914,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
||||
}
|
||||
);
|
||||
dom.append(this.welcomeMessageContainer, this.welcomePart.value.element);
|
||||
|
||||
// Add right-click context menu to the entire welcome container
|
||||
this.welcomeContextMenuDisposable.value = dom.addDisposableListener(this.welcomeMessageContainer, dom.EventType.CONTEXT_MENU, (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.contextMenuService.showContextMenu({
|
||||
menuId: MenuId.ChatWelcomeContext,
|
||||
contextKeyService: this.contextKeyService,
|
||||
getAnchor: () => new StandardMouseEvent(dom.getWindow(this.welcomeMessageContainer), e)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user