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

Add "New Folder" and "Rename" features #1719

Merged
merged 9 commits into from
Oct 3, 2012
Merged

Conversation

gruehle
Copy link
Member

@gruehle gruehle commented Sep 26, 2012

This pull request adds two new features: New Folder, and Rename file/folder.

IMPORTANT: This pull request requires adobe/brackets-shell#120

USAGE

The New Folder command is added to the File menu and the project context menu. When selected, a new folder is created at the same level as the current selection in the project tree. If nothing in the project tree is selected (for example, if a file in the working set is selected), the folder is created at the root of the project folder.

The Rename command is added to the project context menu. It will rename the selected file or folder. Note that the Rename command will only work on project tree items. You cannot rename a file in the working set.

API NOTES

DocumentManager dispatches a new fileNameChange event whenever the name of a file or folder has changed.

DirectoryEntry.getDirectory() is now implemented. This will return a reference to an existing directory or create a new directory if needed.

UNIT TESTS

Unit tests are added for rename(), but not directory creation. We need an API to remove a directory before we can add unit tests that create a directory.

@@ -979,6 +1020,97 @@ define(function (require, exports, module) {
}

/**
* Rename the selected item in the project tree
*/
function renameSelectedItem() {
Copy link
Member

Choose a reason for hiding this comment

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

Drive-by comment: is it worth factoring this so the rename functionality is programmatically accessible? People can't really call the raw fs.rename() directly since it doesn't send out notifications or update any of the UI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. Done.

@peterflynn
Copy link
Member

Oh, one other comment actually -- the inline editor UI shows the filename in two places, so it needs to listen for the notification to. (Or maybe its TextRanges do, and then the inline editor UI listens to something they dispatch in turn).

The Find in Files panel could be another one, but I think since we don't keep it up to date in other cases (e.g. the text content changing causing line numbers to shift) we could safely ignore it for now.

@gruehle
Copy link
Member Author

gruehle commented Sep 28, 2012

For the inline editor, we actually get lucky. Only the filename is shown. If the file is renamed, it is selected before it is renamed, so the inline editor is closed. If a folder containing the file is renamed, no UI needs to change and the functionality works since the underlying document path is changed.

Find in Files has been fixed.

@ghost ghost assigned redmunds Oct 1, 2012
@redmunds
Copy link
Contributor

redmunds commented Oct 1, 2012

On Windows, when you use New Folder, the initial folder named "Untitled" is not sorted correctly. It's listed with the files (at the bottom) and not with the folders (at the top). Even after changing the name, it's still sorted with the files.

@@ -140,6 +143,7 @@ define({
// File menu commands
"FILE_MENU" : "File",
"CMD_FILE_NEW" : "New",
"CMD_FILE_NEW_FOLDER" : "New Folder",
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have "New Folder", I think "New" should be changed to "New File".

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@redmunds
Copy link
Contributor

redmunds commented Oct 2, 2012

Initial review complete

@gruehle
Copy link
Member Author

gruehle commented Oct 2, 2012

Thanks for reviewing! All comments have been addressed and changes pushed.

@redmunds
Copy link
Contributor

redmunds commented Oct 2, 2012

I notice another bug that the "New File" recognizes when a file named Untitled.js already exists, and then generates a unique name (e.g. Untitled-1.js), but "New Folder" does not generate a unique name.

@redmunds
Copy link
Contributor

redmunds commented Oct 3, 2012

UTR BUG: I keep hitting the case where "New File" and "New Folder" stop working, but I can't nail down a reproducible recipe. Anyway, something to be on the lookout for.

@gruehle
Copy link
Member Author

gruehle commented Oct 3, 2012

I fixed the "New Folder" untitled naming problem. I haven't seen cases where "New File" or "New Folder" break. Are you seeing this on Mac or PC?

@njx
Copy link

njx commented Oct 3, 2012

I've seen the failing "New File" in master, so it's not related to Glenn's changes. There seems to be some case where it throws an exception when trying to scroll the new file into view in the project panel. I'll try to find repro steps and file a bug.

@gruehle
Copy link
Member Author

gruehle commented Oct 3, 2012

The selection is now done after sorting. Hopefully this resolves the last issue.

@redmunds
Copy link
Contributor

redmunds commented Oct 3, 2012

Yes, this fixes the selection issue. This pull request is now ready to merge as soon as the necessary brackets-shell pull request gets merged.

@jasonsanjose
Copy link
Member

Merging

jasonsanjose added a commit that referenced this pull request Oct 3, 2012
Add "New Folder" and "Rename" features
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.

5 participants