Skip to content

Commit

Permalink
explorer: do not allow to creatae a new file / folder while in the pr…
Browse files Browse the repository at this point in the history
…ocess of creating a new file

fixes #47606
  • Loading branch information
isidorn committed Apr 19, 2018
1 parent 4638601 commit db9cdda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vs/workbench/parts/files/common/explorerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,14 @@ export class ExplorerItem {
/* A helper that can be used to show a placeholder when creating a new stat */
export class NewStatPlaceholder extends ExplorerItem {

public static NAME = '';
private static ID = 0;

private id: number;
private directoryPlaceholder: boolean;

constructor(isDirectory: boolean, root: ExplorerItem) {
super(URI.file(''), root, false, false, '');
super(URI.file(''), root, false, false, NewStatPlaceholder.NAME);

this.id = NewStatPlaceholder.ID++;
this.isDirectoryResolved = isDirectory;
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/parts/files/electron-browser/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ export class BaseNewAction extends BaseFileAction {
if (!folder) {
return TPromise.wrapError(new Error('Invalid parent folder to create.'));
}
if (!!folder.getChild(NewStatPlaceholder.NAME)) {
// Do not allow to creatae a new file/folder while in the process of creating a new file/folder #47606
return TPromise.as(new Error('Parent folder is already in the process of creating a file'));
}

return this.tree.reveal(folder, 0.5).then(() => {
return this.tree.expand(folder).then(() => {
Expand Down

0 comments on commit db9cdda

Please sign in to comment.