@@ -107,6 +107,8 @@ export class NewFileAction extends BaseErrorReportingAction {
107107 static readonly ID = 'workbench.files.action.createFileFromExplorer' ;
108108 static readonly LABEL = nls . localize ( 'createNewFile' , "New File" ) ;
109109
110+ private toDispose : IDisposable [ ] = [ ] ;
111+
110112 constructor (
111113 private getElement : ( ) => ExplorerItem ,
112114 @INotificationService notificationService : INotificationService ,
@@ -116,6 +118,10 @@ export class NewFileAction extends BaseErrorReportingAction {
116118 ) {
117119 super ( 'explorer.newFile' , NEW_FILE_LABEL , notificationService ) ;
118120 this . class = 'explorer-action new-file' ;
121+ this . toDispose . push ( this . explorerService . onDidChangeEditable ( e => {
122+ const elementIsBeingEdited = this . explorerService . isEditable ( e ) ;
123+ this . enabled = ! elementIsBeingEdited ;
124+ } ) ) ;
119125 }
120126
121127 run ( ) : Promise < any > {
@@ -158,13 +164,20 @@ export class NewFileAction extends BaseErrorReportingAction {
158164 } ) ;
159165 } ) ;
160166 }
167+
168+ dispose ( ) : void {
169+ super . dispose ( ) ;
170+ dispose ( this . toDispose ) ;
171+ }
161172}
162173
163174/* New Folder */
164175export class NewFolderAction extends BaseErrorReportingAction {
165176 static readonly ID = 'workbench.files.action.createFolderFromExplorer' ;
166177 static readonly LABEL = nls . localize ( 'createNewFolder' , "New Folder" ) ;
167178
179+ private toDispose : IDisposable [ ] = [ ] ;
180+
168181 constructor (
169182 private getElement : ( ) => ExplorerItem ,
170183 @INotificationService notificationService : INotificationService ,
@@ -173,6 +186,10 @@ export class NewFolderAction extends BaseErrorReportingAction {
173186 ) {
174187 super ( 'explorer.newFolder' , NEW_FOLDER_LABEL , notificationService ) ;
175188 this . class = 'explorer-action new-folder' ;
189+ this . toDispose . push ( this . explorerService . onDidChangeEditable ( e => {
190+ const elementIsBeingEdited = this . explorerService . isEditable ( e ) ;
191+ this . enabled = ! elementIsBeingEdited ;
192+ } ) ) ;
176193 }
177194
178195 run ( ) : Promise < any > {
@@ -215,6 +232,11 @@ export class NewFolderAction extends BaseErrorReportingAction {
215232 } ) ;
216233 } ) ;
217234 }
235+
236+ dispose ( ) : void {
237+ super . dispose ( ) ;
238+ dispose ( this . toDispose ) ;
239+ }
218240}
219241
220242/* Create new file from anywhere: Open untitled */
0 commit comments