Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Ensure that the baseDir for createNewItem is within the project. #10072

Merged
merged 1 commit into from
Dec 4, 2014

Conversation

dangoor
Copy link
Contributor

@dangoor dangoor commented Dec 3, 2014

This is a fix for #9910.

@busykai
Copy link
Contributor

busykai commented Dec 3, 2014

@dangoor, while reviewing and testing this. I'm curious, which code was triggering the project tree redraw?

@le717
Copy link
Contributor

le717 commented Dec 3, 2014

Hehe, I needed this functionality (getDirectoryInProject()) in my extension a few months ago. I would pull in a path in my project but it would sometimes pull a fuller, incorrect path.

} else if (path && path.isDirectory) {
path = path.fullPath;
} else {
path = null;
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 got it

@RaymondLim
Copy link
Contributor

LGTM. Merging.

RaymondLim added a commit that referenced this pull request Dec 4, 2014
Ensure that the baseDir for createNewItem is within the project.
@RaymondLim RaymondLim merged commit 23a2556 into master Dec 4, 2014
@RaymondLim RaymondLim deleted the dangoor/9910-project-tree-root-dir branch December 4, 2014 19:53
@dangoor
Copy link
Contributor Author

dangoor commented Dec 4, 2014

@busykai the project tree redraws any time the view model changes.

@busykai
Copy link
Contributor

busykai commented Dec 4, 2014

@dangoor, I was trying to understand why the project root in the model would shift, hence the question. thanks!

@dangoor
Copy link
Contributor Author

dangoor commented Dec 5, 2014

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants