fix: copy from context menu for chat references does not work (#236518)

pull/236525/head
Joyce Er 2024-12-18 12:27:49 -08:00 committed by GitHub
parent c88542ef62
commit 1147139fbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 3 deletions

View File

@ -19,7 +19,8 @@ import { localize, localize2 } from '../../../../../nls.js';
import { getFlatContextMenuActions } from '../../../../../platform/actions/browser/menuEntryActionViewItem.js';
import { MenuWorkbenchToolBar } from '../../../../../platform/actions/browser/toolbar.js';
import { Action2, IMenuService, MenuId, registerAction2 } from '../../../../../platform/actions/common/actions.js';
import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
import { IClipboardService } from '../../../../../platform/clipboard/common/clipboardService.js';
import { ContextKeyExpr, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
import { IContextMenuService } from '../../../../../platform/contextview/browser/contextView.js';
import { FileKind } from '../../../../../platform/files/common/files.js';
import { IInstantiationService, ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
@ -476,7 +477,7 @@ registerAction2(class AddToChatAction extends Action2 {
id: MenuId.ChatAttachmentsContext,
group: 'chat',
order: 1,
when: ExplorerFolderContext.negate(),
when: ContextKeyExpr.and(ResourceContextKey.IsFileSystemResource, ExplorerFolderContext.negate()),
}]
});
}
@ -498,4 +499,29 @@ registerAction2(class AddToChatAction extends Action2 {
}
});
registerAction2(class OpenChatReferenceLinkAction extends Action2 {
static readonly id = 'workbench.action.chat.copyLink';
constructor() {
super({
id: OpenChatReferenceLinkAction.id,
title: {
...localize2('copyLink', "Copy Link"),
},
f1: false,
menu: [{
id: MenuId.ChatAttachmentsContext,
group: 'chat',
order: 0,
when: ContextKeyExpr.or(ResourceContextKey.Scheme.isEqualTo(Schemas.http), ResourceContextKey.Scheme.isEqualTo(Schemas.https)),
}]
});
}
override async run(accessor: ServicesAccessor, resource: URI): Promise<void> {
await accessor.get(IClipboardService).writeResources([resource]);
}
});
//#endregion

View File

@ -770,7 +770,7 @@ MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {
group: 'navigation',
order: 10,
command: openToSideCommand,
when: ContextKeyExpr.and(ResourceContextKey.HasResource, ExplorerFolderContext.toNegated())
when: ContextKeyExpr.and(ResourceContextKey.IsFileSystemResource, ExplorerFolderContext.toNegated())
});
MenuRegistry.appendMenuItem(MenuId.ChatAttachmentsContext, {