Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Prevent re-entrancy into handleFileNewInProject(), fixes issue #738 #794

Merged
merged 3 commits into from May 3, 2012

Conversation

Projects
None yet
2 participants
Contributor

tvoliter commented May 3, 2012

handleFileNewInProject() initiates a two step process where the user is first prompted to name a file and then it is written asynchronously to disk. This process must complete before a new file is generated. This change prevents reentrancy and also closes the rename field when the user chooses "new file" during a rename.

I earlier tried a fancier approach that queue up user requests for new files. This got overly complex plus in the future "new file" is likely to create a new in-memory file rather than one on disk. In which case this code will change.

Fixes issue #738

@peterflynn peterflynn commented on the diff May 3, 2012

src/document/DocumentCommandHandlers.js
@@ -257,7 +257,22 @@ define(function (require, exports, module) {
return result.promise();
}
+ /**
+ * Prevent re-entrancy into handleFileNewInProject()
+ *
+ * handleFileNewInProject() first prompts the user to name a file and then asynchronously writes the file when the
+ * filename field loses focus. This boolean prevent additional calls to handleFileNewInProject() when an existing
+ * file creation call is outstanding
+ */
+ var fileNewInProgress = false;
@peterflynn

peterflynn May 3, 2012

Member

Nits:

  • prevent -> prevents
  • Add a space between this var and the function below

@peterflynn peterflynn commented on an outdated diff May 3, 2012

src/project/ProjectManager.js
@@ -778,6 +778,14 @@ define(function (require, exports, module) {
return result.promise();
}
+ /**
+ * Forces createNewItem() to complete by removing focus from the rename field which causes
+ * the new file to be written to disk
+ */
+ function closeRenameInput() {
@peterflynn

peterflynn May 3, 2012

Member

Is there a name that makes it more clear that the outcome is completing the operation rather than canceling it? Maybe something like forceCommitRename() or forceFinishRename()?

Also, we might want to go with something like "FileNaming" instead of "Rename" since it's not really _re_naming an existing file in this case.

Member

peterflynn commented May 3, 2012

Done reviewing. Tested and the behavior seems reasonable enough.

As Ty pointed out, eventually File > New will create a new untitled document (which doesn't get named until you save it), so this is really just a stopgap fix until then.

Contributor

tvoliter commented May 3, 2012

Peter, thanks for the review. My changes are pushed.

I opted for the name "forceFinishRename()". Even though the user isn't naming a file on disk, they are renaming the file in terms of the text presented in the tree since a default name was suggested to them and they get to change it. I can image using this same function in the future during a real file rename so I felt "rename" was better than "name" or "naming field"

Member

peterflynn commented May 3, 2012

Sounds good enough to me

peterflynn added a commit that referenced this pull request May 3, 2012

Merge pull request #794 from adobe/tvoliter/issue-738-round2
Prevent re-entrancy into handleFileNewInProject(), fixes issue #738

@peterflynn peterflynn merged commit f92aa7d into master May 3, 2012

gideonthomas pushed a commit to gideonthomas/brackets that referenced this pull request Jun 22, 2017

Auto resize PNG and JPG images that are more than 250K (#794)
* Auto resize PNG and JPG images that are more than 250K

* Trying Pomax's scaling logic

* Make a best guess for initial scale

* Rework logic, bump max size for resizable images to 12M

* Lint fixes

* Use native canvas/blob methods for reading data, clean up code

* Fix crash in case we exhaust max number of passes.

* Refactor size contstants into Sizes module, delete duplicate code in importers

* Fix lint issue

* reguess

* Remove console.logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment