@@ -140,6 +140,11 @@ export default class PHPValidationProvider {
140140 vscode . commands . executeCommand ( 'setContext' , 'php.untrustValidationExecutableContext' , true ) ;
141141 }
142142
143+ const trustEnabled = vscode . workspace . getConfiguration ( ) . get ( 'security.workspace.trust.enabled' ) ;
144+ if ( trustEnabled ) {
145+ vscode . workspace . requestWorkspaceTrust ( ) ;
146+ }
147+
143148 this . delayers = Object . create ( null ) ;
144149 if ( this . pauseValidation ) {
145150 this . pauseValidation = oldExecutable === this . config . executable ;
@@ -173,9 +178,6 @@ export default class PHPValidationProvider {
173178 return ;
174179 }
175180
176- interface MessageItem extends vscode . MessageItem {
177- id : string ;
178- }
179181
180182 let trigger = ( ) => {
181183 let key = textDocument . uri . toString ( ) ;
@@ -187,35 +189,50 @@ export default class PHPValidationProvider {
187189 delayer . trigger ( ( ) => this . doValidate ( textDocument ) ) ;
188190 } ;
189191
190- if ( this . config ! . executableIsUserDefined !== undefined && ! this . config ! . executableIsUserDefined ) {
192+ const trustEnabled = vscode . workspace . getConfiguration ( ) . get ( 'security.workspace.trust.enabled' ) ;
193+ if ( trustEnabled ) {
194+ if ( vscode . workspace . isTrusted ) {
195+ trigger ( ) ;
196+ }
197+ } else if ( this . config ! . executableIsUserDefined !== undefined && ! this . config ! . executableIsUserDefined ) {
191198 const checkedExecutablePath = this . workspaceStore . get < string | undefined > ( Setting . CheckedExecutablePath , undefined ) ;
192199 if ( ! checkedExecutablePath || checkedExecutablePath !== this . config ! . executable ) {
193- const selected = await vscode . window . showInformationMessage < MessageItem > (
194- localize ( 'php.useExecutablePath' , 'Do you allow {0} (defined as a workspace setting) to be executed to lint PHP files?' , this . config ! . executable ) ,
195- {
196- title : localize ( 'php.yes' , 'Allow' ) ,
197- id : 'yes'
198- } ,
199- {
200- title : localize ( 'php.no' , 'Disallow' ) ,
201- isCloseAffordance : true ,
202- id : 'no'
203- }
204- ) ;
205-
206- if ( ! selected || selected . id === 'no' ) {
207- this . pauseValidation = true ;
208- } else if ( selected . id === 'yes' ) {
200+ if ( await this . showCustomTrustDialog ( ) ) {
209201 this . workspaceStore . update ( Setting . CheckedExecutablePath , this . config ! . executable ) ;
210202 vscode . commands . executeCommand ( 'setContext' , 'php.untrustValidationExecutableContext' , true ) ;
211- trigger ( ) ;
203+ } else {
204+ this . pauseValidation = true ;
205+ return ;
212206 }
207+ }
213208
214- return ;
209+ trigger ( ) ;
210+ }
211+ }
212+
213+ private async showCustomTrustDialog ( ) : Promise < boolean > {
214+ interface MessageItem extends vscode . MessageItem {
215+ id : string ;
216+ }
217+
218+ const selected = await vscode . window . showInformationMessage < MessageItem > (
219+ localize ( 'php.useExecutablePath' , 'Do you allow {0} (defined as a workspace setting) to be executed to lint PHP files?' , this . config ! . executable ) ,
220+ {
221+ title : localize ( 'php.yes' , 'Allow' ) ,
222+ id : 'yes'
223+ } ,
224+ {
225+ title : localize ( 'php.no' , 'Disallow' ) ,
226+ isCloseAffordance : true ,
227+ id : 'no'
215228 }
229+ ) ;
230+
231+ if ( selected && selected . id === 'yes' ) {
232+ return true ;
216233 }
217234
218- trigger ( ) ;
235+ return false ;
219236 }
220237
221238 private doValidate ( textDocument : vscode . TextDocument ) : Promise < void > {
0 commit comments