@@ -10,15 +10,15 @@ import { coalesce } from '../../../../base/common/arrays.js';
10
10
import { Codicon } from '../../../../base/common/codicons.js' ;
11
11
import { IDisposable } from '../../../../base/common/lifecycle.js' ;
12
12
import { Mimes } from '../../../../base/common/mime.js' ;
13
- import { basename , joinPath } from '../../../../base/common/resources.js' ;
13
+ import { basename } from '../../../../base/common/resources.js' ;
14
14
import { URI } from '../../../../base/common/uri.js' ;
15
15
import { IRange } from '../../../../editor/common/core/range.js' ;
16
16
import { SymbolKinds } from '../../../../editor/common/languages.js' ;
17
17
import { ITextModelService } from '../../../../editor/common/services/resolverService.js' ;
18
18
import { localize } from '../../../../nls.js' ;
19
19
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js' ;
20
20
import { CodeDataTransfers , containsDragType , DocumentSymbolTransferData , extractEditorsDropData , extractMarkerDropData , extractSymbolDropData , IDraggedResourceEditorInput , MarkerTransferData } from '../../../../platform/dnd/browser/dnd.js' ;
21
- import { FileType , IFileService , IFileSystemProvider } from '../../../../platform/files/common/files.js' ;
21
+ import { IFileService } from '../../../../platform/files/common/files.js' ;
22
22
import { MarkerSeverity } from '../../../../platform/markers/common/markers.js' ;
23
23
import { IThemeService , Themable } from '../../../../platform/theme/common/themeService.js' ;
24
24
import { isUntitledResourceEditorInput } from '../../../common/editor.js' ;
@@ -48,14 +48,14 @@ export class ChatDragAndDrop extends Themable {
48
48
private overlayTextBackground : string = '' ;
49
49
50
50
constructor (
51
- protected readonly attachmentModel : ChatAttachmentModel ,
51
+ private readonly attachmentModel : ChatAttachmentModel ,
52
52
private readonly styles : IChatInputStyles ,
53
53
@IThemeService themeService : IThemeService ,
54
54
@IExtensionService private readonly extensionService : IExtensionService ,
55
- @IFileService protected readonly fileService : IFileService ,
56
- @IEditorService protected readonly editorService : IEditorService ,
57
- @IDialogService protected readonly dialogService : IDialogService ,
58
- @ITextModelService protected readonly textModelService : ITextModelService
55
+ @IFileService private readonly fileService : IFileService ,
56
+ @IEditorService private readonly editorService : IEditorService ,
57
+ @IDialogService private readonly dialogService : IDialogService ,
58
+ @ITextModelService private readonly textModelService : ITextModelService
59
59
) {
60
60
super ( themeService ) ;
61
61
@@ -150,10 +150,6 @@ export class ChatDragAndDrop extends Themable {
150
150
return ;
151
151
}
152
152
153
- this . handleDrop ( contexts ) ;
154
- }
155
-
156
- protected handleDrop ( contexts : IChatRequestVariableEntry [ ] ) : void {
157
153
this . attachmentModel . addContext ( ...contexts ) ;
158
154
}
159
155
@@ -193,7 +189,7 @@ export class ChatDragAndDrop extends Themable {
193
189
return dropType !== undefined ;
194
190
}
195
191
196
- protected getDropTypeName ( type : ChatDragAndDropType ) : string {
192
+ private getDropTypeName ( type : ChatDragAndDropType ) : string {
197
193
switch ( type ) {
198
194
case ChatDragAndDropType . FILE_INTERNAL : return localize ( 'file' , 'File' ) ;
199
195
case ChatDragAndDropType . FILE_EXTERNAL : return localize ( 'file' , 'File' ) ;
@@ -412,7 +408,7 @@ export class ChatDragAndDrop extends Themable {
412
408
overlay . classList . toggle ( 'visible' , type !== undefined ) ;
413
409
}
414
410
415
- protected getOverlayText ( type : ChatDragAndDropType ) : string {
411
+ private getOverlayText ( type : ChatDragAndDropType ) : string {
416
412
const typeName = this . getDropTypeName ( type ) ;
417
413
return localize ( 'attacAsContext' , 'Attach {0} as Context' , typeName ) ;
418
414
}
@@ -428,81 +424,6 @@ export class ChatDragAndDrop extends Themable {
428
424
}
429
425
}
430
426
431
- export class EditsDragAndDrop extends ChatDragAndDrop {
432
-
433
- constructor (
434
- attachmentModel : ChatAttachmentModel ,
435
- styles : IChatInputStyles ,
436
- @IThemeService themeService : IThemeService ,
437
- @IExtensionService extensionService : IExtensionService ,
438
- @IFileService fileService : IFileService ,
439
- @IEditorService editorService : IEditorService ,
440
- @IDialogService dialogService : IDialogService ,
441
- @ITextModelService textModelService : ITextModelService
442
- ) {
443
- super ( attachmentModel , styles , themeService , extensionService , fileService , editorService , dialogService , textModelService ) ;
444
- }
445
-
446
- protected override handleDrop ( context : IChatRequestVariableEntry [ ] ) : void {
447
- this . handleDropAsync ( context ) ;
448
- }
449
-
450
- protected async handleDropAsync ( context : IChatRequestVariableEntry [ ] ) : Promise < void > {
451
- const nonDirectoryContext = context . filter ( context => ! context . isDirectory ) ;
452
- const directories = context
453
- . filter ( context => context . isDirectory )
454
- . map ( context => context . value )
455
- . filter ( value => ! ! value && URI . isUri ( value ) ) ;
456
-
457
- // If there are directories, we need to resolve the files and add them to the working set
458
- for ( const directory of directories ) {
459
- const fileSystemProvider = this . fileService . getProvider ( directory . scheme ) ;
460
- if ( ! fileSystemProvider ) {
461
- continue ;
462
- }
463
-
464
- const resolvedFiles = await resolveFilesInDirectory ( directory , fileSystemProvider , true ) ;
465
- const resolvedFileContext = await Promise . all ( resolvedFiles . map ( file => getResourceAttachContext ( file , false , this . textModelService ) ) ) ;
466
- nonDirectoryContext . push ( ...resolvedFileContext . filter ( context => ! ! context ) ) ;
467
- }
468
-
469
- super . handleDrop ( nonDirectoryContext ) ;
470
- }
471
-
472
- protected override getOverlayText ( type : ChatDragAndDropType ) : string {
473
- const typeName = this . getDropTypeName ( type ) ;
474
- switch ( type ) {
475
- case ChatDragAndDropType . FILE_INTERNAL :
476
- case ChatDragAndDropType . FILE_EXTERNAL :
477
- return localize ( 'addToWorkingSet' , 'Add {0} to Working Set' , typeName ) ;
478
- case ChatDragAndDropType . FOLDER :
479
- return localize ( 'addToWorkingSet' , 'Add {0} to Working Set' , localize ( 'files' , 'Files' ) ) ;
480
- default :
481
- return super . getOverlayText ( type ) ;
482
- }
483
- }
484
- }
485
-
486
- async function resolveFilesInDirectory ( resource : URI , fileSystemProvider : IFileSystemProvider , shouldRecurse : boolean ) : Promise < URI [ ] > {
487
- const entries = await fileSystemProvider . readdir ( resource ) ;
488
-
489
- const files : URI [ ] = [ ] ;
490
- const folders : URI [ ] = [ ] ;
491
-
492
- for ( const [ name , type ] of entries ) {
493
- const entryResource = joinPath ( resource , name ) ;
494
- if ( type === FileType . File ) {
495
- files . push ( entryResource ) ;
496
- } else if ( type === FileType . Directory && shouldRecurse ) {
497
- folders . push ( entryResource ) ;
498
- }
499
- }
500
-
501
- const subFiles = await Promise . all ( folders . map ( folder => resolveFilesInDirectory ( folder , fileSystemProvider , shouldRecurse ) ) ) ;
502
-
503
- return [ ...files , ...subFiles . flat ( ) ] ;
504
- }
505
-
506
427
async function getResourceAttachContext ( resource : URI , isDirectory : boolean , textModelService : ITextModelService ) : Promise < IChatRequestVariableEntry | undefined > {
507
428
let isOmitted = false ;
508
429
0 commit comments