@@ -23,7 +23,7 @@ import { extUriBiasedIgnorePathCase, normalizePath, relativePath } from '../../.
23
23
import { URI } from '../../../util/vs/base/common/uri' ;
24
24
import { Position as EditorPosition } from '../../../util/vs/editor/common/core/position' ;
25
25
import { ServicesAccessor } from '../../../util/vs/platform/instantiation/common/instantiation' ;
26
- import { EndOfLine , MarkdownString , Position , Range , TextEdit } from '../../../vscodeTypes' ;
26
+ import { EndOfLine , Position , Range , TextEdit } from '../../../vscodeTypes' ;
27
27
28
28
// Simplified Hunk type for the patch
29
29
interface Hunk {
@@ -561,9 +561,10 @@ const platformConfirmationRequiredPaths = (
561
561
562
562
const enum ConfirmationCheckResult {
563
563
NoConfirmation ,
564
+ NoPermissions ,
564
565
Sensitive ,
565
566
SystemFile ,
566
- OutsideWorkspace
567
+ OutsideWorkspace ,
567
568
}
568
569
569
570
/**
@@ -624,6 +625,9 @@ function makeUriConfirmationChecker(configuration: IConfigurationService, worksp
624
625
toCheck . push ( URI . file ( linked ) ) ;
625
626
}
626
627
} catch ( e ) {
628
+ if ( ( e as NodeJS . ErrnoException ) . code === 'EPERM' ) {
629
+ return ConfirmationCheckResult . NoPermissions ;
630
+ }
627
631
// Usually EPERM or ENOENT on the linkedFile
628
632
}
629
633
}
@@ -648,17 +652,21 @@ export async function createEditConfirmation(accessor: ServicesAccessor, uris: r
648
652
return '`' + ( wf ? relativePath ( wf , uri ) : uri . fsPath ) + '`' ;
649
653
} ) . join ( ', ' ) ;
650
654
655
+ let message : string ;
656
+ if ( needsConfirmation . some ( r => r . reason === ConfirmationCheckResult . NoPermissions ) ) {
657
+ message = t `The model wants to edit files you don't have permission to modify (${ fileParts } ).` ;
658
+ } else if ( needsConfirmation . some ( r => r . reason === ConfirmationCheckResult . Sensitive ) ) {
659
+ message = t `The model wants to edit sensitive files (${ fileParts } ).` ;
660
+ } else if ( needsConfirmation . some ( r => r . reason === ConfirmationCheckResult . OutsideWorkspace ) ) {
661
+ message = t `The model wants to edit files outside of your workspace (${ fileParts } ).` ;
662
+ } else {
663
+ message = t `The model wants to edit system files (${ fileParts } ).` ;
664
+ }
665
+
651
666
return {
652
667
confirmationMessages : {
653
668
title : t ( 'Allow edits to sensitive files?' ) ,
654
- message : new MarkdownString (
655
- ( needsConfirmation . some ( r => r . reason === ConfirmationCheckResult . Sensitive )
656
- ? t `The model wants to edit sensitive files (${ fileParts } ).`
657
- : needsConfirmation . some ( r => r . reason === ConfirmationCheckResult . OutsideWorkspace )
658
- ? t `The model wants to edit files outside of your workspace (${ fileParts } ).`
659
- : t `The model wants to edit system files (${ fileParts } ).` )
660
- + ' ' + t `Do you want to allow this?` + '\n\n' + asString ( )
661
- ) ,
669
+ message : message + ' ' + t `Do you want to allow this?` + '\n\n' + asString ( ) ,
662
670
}
663
671
} ;
664
672
}
0 commit comments