@@ -25,11 +25,14 @@ import { IFileService } from '../../../../../platform/files/common/files.js';
25
25
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js' ;
26
26
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js' ;
27
27
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
28
+ import { IListService } from '../../../../../platform/list/browser/listService.js' ;
28
29
import { ILogService } from '../../../../../platform/log/common/log.js' ;
29
30
import { AnythingQuickAccessProviderRunOptions } from '../../../../../platform/quickinput/common/quickAccess.js' ;
30
31
import { IQuickInputService , IQuickPickItem , IQuickPickItemWithResource , QuickPickItem } from '../../../../../platform/quickinput/common/quickInput.js' ;
32
+ import { resolveCommandsContext } from '../../../../browser/parts/editor/editorCommandsContext.js' ;
31
33
import { ResourceContextKey } from '../../../../common/contextkeys.js' ;
32
- import { EditorResourceAccessor , SideBySideEditor } from '../../../../common/editor.js' ;
34
+ import { EditorResourceAccessor , isEditorCommandsContext , SideBySideEditor } from '../../../../common/editor.js' ;
35
+ import { IEditorGroupsService } from '../../../../services/editor/common/editorGroupsService.js' ;
33
36
import { IEditorService } from '../../../../services/editor/common/editorService.js' ;
34
37
import { IViewsService } from '../../../../services/views/common/viewsService.js' ;
35
38
import { ExplorerFolderContext } from '../../../files/common/files.js' ;
@@ -82,7 +85,7 @@ abstract class AttachResourceAction extends Action2 {
82
85
protected _getResources ( accessor : ServicesAccessor , ...args : any [ ] ) : URI [ ] {
83
86
const editorService = accessor . get ( IEditorService ) ;
84
87
85
- const contexts = Array . isArray ( args [ 1 ] ) ? args [ 1 ] : [ args [ 0 ] ] ;
88
+ const contexts = isEditorCommandsContext ( args [ 1 ] ) ? this . _getEditorResources ( accessor , args ) : Array . isArray ( args [ 1 ] ) ? args [ 1 ] : [ args [ 0 ] ] ;
86
89
const files = [ ] ;
87
90
for ( const context of contexts ) {
88
91
let uri ;
@@ -103,6 +106,15 @@ abstract class AttachResourceAction extends Action2 {
103
106
104
107
return files ;
105
108
}
109
+
110
+ private _getEditorResources ( accessor : ServicesAccessor , ...args : any [ ] ) : URI [ ] {
111
+ const resolvedContext = resolveCommandsContext ( args , accessor . get ( IEditorService ) , accessor . get ( IEditorGroupsService ) , accessor . get ( IListService ) ) ;
112
+
113
+ return resolvedContext . groupedEditors
114
+ . flatMap ( groupedEditor => groupedEditor . editors )
115
+ . map ( editor => EditorResourceAccessor . getCanonicalUri ( editor , { supportSideBySide : SideBySideEditor . PRIMARY } ) )
116
+ . filter ( uri => uri !== undefined ) ;
117
+ }
106
118
}
107
119
108
120
class AttachFileToChatAction extends AttachResourceAction {
@@ -122,8 +134,8 @@ class AttachFileToChatAction extends AttachResourceAction {
122
134
order : 1 ,
123
135
when : ContextKeyExpr . and ( ChatContextKeys . enabled , SearchContext . FileMatchOrMatchFocusKey , SearchContext . SearchResultHeaderFocused . negate ( ) ) ,
124
136
} , {
125
- id : MenuId . ChatExplorerMenu ,
126
- group : 'zContext ' ,
137
+ id : MenuId . ExplorerContext ,
138
+ group : '5_chat ' ,
127
139
order : 1 ,
128
140
when : ContextKeyExpr . and (
129
141
ChatContextKeys . enabled ,
@@ -135,7 +147,7 @@ class AttachFileToChatAction extends AttachResourceAction {
135
147
) ,
136
148
} , {
137
149
id : MenuId . EditorTitleContext ,
138
- group : 'zContext ' ,
150
+ group : '2_chat ' ,
139
151
order : 1 ,
140
152
when : ContextKeyExpr . and (
141
153
ChatContextKeys . enabled ,
@@ -145,8 +157,8 @@ class AttachFileToChatAction extends AttachResourceAction {
145
157
)
146
158
) ,
147
159
} , {
148
- id : MenuId . ChatTextEditorMenu ,
149
- group : 'zContext ' ,
160
+ id : MenuId . EditorContext ,
161
+ group : '1_chat ' ,
150
162
order : 2 ,
151
163
when : ContextKeyExpr . and (
152
164
ChatContextKeys . enabled ,
@@ -186,8 +198,8 @@ class AttachFolderToChatAction extends AttachResourceAction {
186
198
category : CHAT_CATEGORY ,
187
199
f1 : false ,
188
200
menu : {
189
- id : MenuId . ChatExplorerMenu ,
190
- group : 'zContext ' ,
201
+ id : MenuId . ExplorerContext ,
202
+ group : '5_chat ' ,
191
203
order : 1 ,
192
204
when : ContextKeyExpr . and (
193
205
ChatContextKeys . enabled ,
@@ -227,8 +239,8 @@ class AttachSelectionToChatAction extends Action2 {
227
239
f1 : true ,
228
240
precondition : ChatContextKeys . enabled ,
229
241
menu : {
230
- id : MenuId . ChatTextEditorMenu ,
231
- group : 'zContext ' ,
242
+ id : MenuId . EditorContext ,
243
+ group : '1_chat ' ,
232
244
order : 1 ,
233
245
when : ContextKeyExpr . and (
234
246
ChatContextKeys . enabled ,
0 commit comments