-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Ensure that the baseDir for createNewItem is within the project. #10072
Conversation
This is a fix for #9910.
@dangoor, while reviewing and testing this. I'm curious, which code was triggering the project tree redraw? |
Hehe, I needed this functionality ( |
} else if (path && path.isDirectory) { | ||
path = path.fullPath; | ||
} else { | ||
path = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't just return null. We need to fix it below to the project root since the caller is expecting a valid directory in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this function always returns a valid directory in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 got it
LGTM. Merging. |
Ensure that the baseDir for createNewItem is within the project.
@busykai the project tree redraws any time the view model changes. |
@dangoor, I was trying to understand why the project root in the model would shift, hence the question. thanks! |
@busykai I didn't dive into that, but my guess is that the absolute path was sent all the way through, so the FileTreeViewModel then had to account for all of those extra directories. You do raise a good question, though: it would likely be better for that absolute path to be rejected at that point that it was introduced. The fix in this pull request is still the right fix for this particular problem, because when you create a file or directory by clicking in the blank space it should create the new item in the project rather than rejecting. |
This is a fix for #9910.