From 51d7c2c8a94415448a863e909b7d9c06953694cb Mon Sep 17 00:00:00 2001 From: Gabriel Cardoso Date: Fri, 14 Dec 2012 11:31:57 -0200 Subject: [PATCH 1/3] Issue #1976 - Rename on second click --- src/project/FileViewController.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index a8791fa0c1f..eca5a8fce02 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -138,7 +138,8 @@ define(function (require, exports, module) { * @returns {$.Promise} */ function openAndSelectDocument(fullPath, fileSelectionFocus) { - var result; + var rename = _fileSelectionFocus === fileSelectionFocus && fileSelectionFocus === WORKING_SET_VIEW, + result; if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) { throw new Error("Bad parameter passed to FileViewController.openAndSelectDocument"); @@ -156,8 +157,12 @@ define(function (require, exports, module) { // in this case to signify the selection focus has changed even though the current document has not. var curDoc = DocumentManager.getCurrentDocument(); if (curDoc && curDoc.file.fullPath === fullPath) { - _selectCurrentDocument(); - result = (new $.Deferred()).resolve().promise(); + if (rename) { + result = CommandManager.execute(Commands.FILE_RENAME); + } else { + _selectCurrentDocument(); + result = (new $.Deferred()).resolve().promise(); + } } else { result = CommandManager.execute(Commands.FILE_OPEN, {fullPath: fullPath}); } From 9bdb99230891ce786c21bedb2da824453e1a0abb Mon Sep 17 00:00:00 2001 From: Gabriel Cardoso Date: Mon, 17 Dec 2012 13:34:56 -0200 Subject: [PATCH 2/3] Fixing rename on second click - Issue #1976 Remove it from FileViewController.openAndSelectDocument method and add it to WorkingSetView drop event. --- src/project/FileViewController.js | 11 +++-------- src/project/WorkingSetView.js | 6 +++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index eca5a8fce02..a8791fa0c1f 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -138,8 +138,7 @@ define(function (require, exports, module) { * @returns {$.Promise} */ function openAndSelectDocument(fullPath, fileSelectionFocus) { - var rename = _fileSelectionFocus === fileSelectionFocus && fileSelectionFocus === WORKING_SET_VIEW, - result; + var result; if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) { throw new Error("Bad parameter passed to FileViewController.openAndSelectDocument"); @@ -157,12 +156,8 @@ define(function (require, exports, module) { // in this case to signify the selection focus has changed even though the current document has not. var curDoc = DocumentManager.getCurrentDocument(); if (curDoc && curDoc.file.fullPath === fullPath) { - if (rename) { - result = CommandManager.execute(Commands.FILE_RENAME); - } else { - _selectCurrentDocument(); - result = (new $.Deferred()).resolve().promise(); - } + _selectCurrentDocument(); + result = (new $.Deferred()).resolve().promise(); } else { result = CommandManager.execute(Commands.FILE_OPEN, {fullPath: fullPath}); } diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index fa5ab3c4505..07f6843badb 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -228,7 +228,11 @@ define(function (require, exports, module) { // If file wasnt moved open or close it if (!moved) { if (!fromClose) { - FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + if (selected) { + CommandManager.execute(Commands.FILE_RENAME); + } else { + FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } } else { CommandManager.execute(Commands.FILE_CLOSE, {file: $listItem.data(_FILE_KEY)}); } From f0090e600718b8e2c92527a731c6e455c9fc0c57 Mon Sep 17 00:00:00 2001 From: Gabriel Cardoso Date: Mon, 17 Dec 2012 16:25:58 -0200 Subject: [PATCH 3/3] Fixing rename on second click - Issue #1976 Fixing indenting. --- src/project/WorkingSetView.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 07f6843badb..be2cd636f2b 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -228,11 +228,11 @@ define(function (require, exports, module) { // If file wasnt moved open or close it if (!moved) { if (!fromClose) { - if (selected) { + if (selected) { CommandManager.execute(Commands.FILE_RENAME); - } else { + } else { FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); - } + } } else { CommandManager.execute(Commands.FILE_CLOSE, {file: $listItem.data(_FILE_KEY)}); }