From c159aca808391ff71aac5d7448b6abe1eae0255e Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Thu, 11 Jul 2013 10:32:53 +1000 Subject: [PATCH 01/15] Adds directory names to the files in working tree, when multiple files with the same name are opened there. --- src/project/WorkingSetView.js | 56 +++++++++++++++++++++++++++++++++++ src/styles/brackets.less | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 92f65949d6c..778adbc54a1 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -39,6 +39,7 @@ define(function (require, exports, module) { Commands = require("command/Commands"), Menus = require("command/Menus"), FileViewController = require("project/FileViewController"), + CollectionUtils = require("utils/CollectionUtils"), ViewUtils = require("utils/ViewUtils"); @@ -76,6 +77,60 @@ define(function (require, exports, module) { } } + /** + * Adds directory names to elements representing passed files in working tree + * @private + * @param {Array.} fileArray + */ + function _addDirectoryNamesToWorkingTreeFiles(filesList) { + $openFilesContainer.find("ul > li").each(function () { + var $li = $(this); + var file = $li.data(_FILE_KEY); + if (filesList.indexOf(file) !== -1) { + var dirNameEnd = file.fullPath.lastIndexOf("/"); + var dirNameStart = file.fullPath.lastIndexOf("/", dirNameEnd - 1) + 1; + var dirName = file.fullPath.substring(dirNameStart, dirNameEnd); + var $dir = $("").text(" | " + dirName); + + var $a = $li.children("a"); + $a.children("span.directory").remove(); + $a.append($dir); + } + }); + } + + /** + * Looks for files with the same name in the working set + * and adds a parent directory name to them + * @private + */ + function _checkForDuplicatesInWorkingTree() { + var map = {}, + fileList = DocumentManager.getWorkingSet(); + + // go through files and fill map with arrays of duplicates + fileList.forEach(function (file) { + // use the same function that is used to create html for file + var displayHtml = ViewUtils.getFileEntryDisplay(file); + + if (map[displayHtml] === undefined) { + map[displayHtml] = file; + } else { + if (!(map[displayHtml] instanceof Array)) { + map[displayHtml] = [map[displayHtml]]; + } + map[displayHtml].push(file); + } + }); + + // go through map and solve arrays, ignore rest + CollectionUtils.forEach(map, function (value) { + if (value instanceof Array) { + _addDirectoryNamesToWorkingTreeFiles(value); + } + }); + } + /** * @private * Shows/Hides open files list based on working set content. @@ -87,6 +142,7 @@ define(function (require, exports, module) { } else { $openFilesContainer.show(); $workingSetHeader.show(); + _checkForDuplicatesInWorkingTree(); } _adjustForScrollbars(); _fireSelectionChanged(); diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 9e4f4de0378..3f359b279b7 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -413,7 +413,7 @@ a, img { cursor: default; } - .extension { + .extension, .directory { color: @project-panel-text-2; } } From 35b366899bba2f2695f1b415cae2f160edce10be Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sat, 13 Jul 2013 22:32:45 +1000 Subject: [PATCH 02/15] Changed font size of directory to 11px and using mdash as separator --- src/project/WorkingSetView.js | 2 +- src/styles/brackets.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 778adbc54a1..29641b9e5e2 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -90,7 +90,7 @@ define(function (require, exports, module) { var dirNameEnd = file.fullPath.lastIndexOf("/"); var dirNameStart = file.fullPath.lastIndexOf("/", dirNameEnd - 1) + 1; var dirName = file.fullPath.substring(dirNameStart, dirNameEnd); - var $dir = $("").text(" | " + dirName); + var $dir = $("").html(" — " + dirName); var $a = $li.children("a"); $a.children("span.directory").remove(); diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 3f359b279b7..dc68b65e943 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -411,6 +411,10 @@ a, img { padding: 3px (@sidebar-triangle-size * 2) 3px 0; cursor: default; + + .directory { + font-size: 11px; + } } .extension, .directory { From 988293c11384e8b93e32ca86ff18f1e26151c87d Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Wed, 31 Jul 2013 10:24:43 +1000 Subject: [PATCH 03/15] WorkingSetView test for directory name functionality when multiple files with same name are opened. --- .../directory/file_one.js | 0 test/spec/WorkingSetView-test.js | 40 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/spec/WorkingSetView-test-files/directory/file_one.js diff --git a/test/spec/WorkingSetView-test-files/directory/file_one.js b/test/spec/WorkingSetView-test-files/directory/file_one.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index dbb7cd43568..fafaecafda7 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -41,6 +41,8 @@ define(function (require, exports, module) { var testPath = SpecRunnerUtils.getTestPath("/spec/WorkingSetView-test-files"); var testWindow; + var openAndMakeDirty; + var workingSetCount; beforeEach(function () { SpecRunnerUtils.createTestWindowAndRun(this, function (w) { @@ -56,7 +58,7 @@ define(function (require, exports, module) { SpecRunnerUtils.loadProjectInTestWindow(testPath); }); - var workingSetCount = 0; + workingSetCount = 0; runs(function () { // Initialize: register listeners @@ -65,7 +67,7 @@ define(function (require, exports, module) { }); }); - var openAndMakeDirty = function (path) { + openAndMakeDirty = function (path) { var doc, didOpen = false, gotError = false; // open file @@ -92,6 +94,8 @@ define(function (require, exports, module) { afterEach(function () { testWindow = null; + openAndMakeDirty = null; + workingSetCount = null; CommandManager = null; Commands = null; DocumentManager = null; @@ -252,6 +256,38 @@ define(function (require, exports, module) { expect($projectFileItems.find("a.jstree-clicked").eq(0).siblings("input").eq(0).val()).toBe(fileName); }); }); + + it("should show a directory name next to the file name when two files with same names are opened", function () { + runs(function() { + // Count currently opened files + var workingSetCountBeforeTest = workingSetCount; + + // First we need to open another file + openAndMakeDirty(testPath + "/directory/file_one.js"); + + // Wait for file to be added to the working set + waitsFor(function () { return workingSetCount === workingSetCountBeforeTest + 1; }, 1000); + + runs(function() { + // Two files with the same name file_one.js should be now opened + var $list = testWindow.$("#open-files-container > ul"); + expect($list.find(".directory").length).toBe(2); + + // Now close last opened file to hide the directories again + DocumentManager.getCurrentDocument()._markClean(); // so we can close without a save dialog + var didClose = false, gotError = false; + CommandManager.execute(Commands.FILE_CLOSE) + .done(function () { didClose = true; }) + .fail(function () { gotError = true; }); + waitsFor(function () { return didClose && !gotError; }, "timeout on FILE_CLOSE", 1000); + + // there should be no more directories shown + runs(function () { + expect($list.find(".directory").length).toBe(0); + }); + }); + }); + }); }); }); \ No newline at end of file From 46bcbd7d6095418d3c9efd65cc119e694a646e18 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Wed, 31 Jul 2013 10:34:06 +1000 Subject: [PATCH 04/15] Fixed an issue where directory name stayed displayed after closing one of two files with duplicate filename. --- src/project/WorkingSetView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 29641b9e5e2..dd86de947a0 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -91,10 +91,7 @@ define(function (require, exports, module) { var dirNameStart = file.fullPath.lastIndexOf("/", dirNameEnd - 1) + 1; var dirName = file.fullPath.substring(dirNameStart, dirNameEnd); var $dir = $("").html(" — " + dirName); - - var $a = $li.children("a"); - $a.children("span.directory").remove(); - $a.append($dir); + $li.children("a").append($dir); } }); } @@ -108,6 +105,9 @@ define(function (require, exports, module) { var map = {}, fileList = DocumentManager.getWorkingSet(); + // we need to always clear current directories as files could be removed from working tree + $openFilesContainer.find("ul > li > a > span.directory").remove(); + // go through files and fill map with arrays of duplicates fileList.forEach(function (file) { // use the same function that is used to create html for file From 38519fccba17d5863200efcd31170b49afd7c339 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Fri, 2 Aug 2013 09:40:46 +1000 Subject: [PATCH 05/15] Added test for different directory names, when two files of the same name are opened, located in folders with same name. --- .../directory/directory/file_one.js | 0 test/spec/WorkingSetView-test.js | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/spec/WorkingSetView-test-files/directory/directory/file_one.js diff --git a/test/spec/WorkingSetView-test-files/directory/directory/file_one.js b/test/spec/WorkingSetView-test-files/directory/directory/file_one.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index fafaecafda7..e2155aeef6a 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -288,6 +288,38 @@ define(function (require, exports, module) { }); }); }); + + it("should show different directory names, when two files of the same name are opened, located in folders with same name", function () { + runs(function () { + // Count currently opened files + var workingSetCountBeforeTest = workingSetCount; + + // Open both files + openAndMakeDirty(testPath + "/directory/file_one.js"); + openAndMakeDirty(testPath + "/directory/directory/file_one.js"); + + // Wait for them to load + waitsFor(function () { return workingSetCount === workingSetCountBeforeTest + 2; }, 1000); + + runs(function() { + // Collect all directory names displayed + var $list = testWindow.$("#open-files-container > ul"); + var names = $list.find(".directory").map(function () { + return $(this).text(); + }).toArray(); + + // All directory names should be unique + var uniq = 0, map = {}; + names.forEach(function(name) { + if (!map[name]) { + map[name] = true; + uniq++; + } + }); + expect(uniq).toBe(names.length); + }); + }); + }); }); }); \ No newline at end of file From 6d8942281557ebd86053aa92ba5abec64c181d5f Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Fri, 2 Aug 2013 10:11:39 +1000 Subject: [PATCH 06/15] Fixed an issue when multiple directories should be displayed next to the filename. --- src/project/WorkingSetView.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index dd86de947a0..5d28871dff0 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -83,13 +83,40 @@ define(function (require, exports, module) { * @param {Array.} fileArray */ function _addDirectoryNamesToWorkingTreeFiles(filesList) { + // First collect fullPaths from the list of files + var filePaths = []; + filesList.forEach(function (file, index) { + var fp = file.fullPath.split('/'); + fp.pop(); // Remove the filename itself + filePaths[index] = fp; + }); + + // Then go through all the paths and shift them until a difference is found + var foundDiff = false; + do { + var i, + l = filePaths.length, + firstVal = filePaths[0][0]; + for (i = 1; i < l; i++) { + if (filePaths[i][0] !== firstVal) { + foundDiff = true; + break; + } + } + if (!foundDiff) { + for (i = 0; i < l; i++) { + filePaths[i].shift(); + } + } + } while (!foundDiff); + + // Go through open files and add directories to appropriate entries $openFilesContainer.find("ul > li").each(function () { var $li = $(this); var file = $li.data(_FILE_KEY); - if (filesList.indexOf(file) !== -1) { - var dirNameEnd = file.fullPath.lastIndexOf("/"); - var dirNameStart = file.fullPath.lastIndexOf("/", dirNameEnd - 1) + 1; - var dirName = file.fullPath.substring(dirNameStart, dirNameEnd); + var io = filesList.indexOf(file); + if (io !== -1) { + var dirName = filePaths[io].join('/'); var $dir = $("").html(" — " + dirName); $li.children("a").append($dir); } From 280b82a5922c82b137165690f586ded116e661b3 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Fri, 2 Aug 2013 10:50:13 +1000 Subject: [PATCH 07/15] Fixing nearest uncommon directory algorithm, just to be sure infinite loops won't happen. --- src/project/WorkingSetView.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 5d28871dff0..03a9dcd3ec8 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -83,6 +83,11 @@ define(function (require, exports, module) { * @param {Array.} fileArray */ function _addDirectoryNamesToWorkingTreeFiles(filesList) { + // filesList must have at least two files in it for this to make sense + if (filesList.length <= 1) { + return; + } + // First collect fullPaths from the list of files var filePaths = []; filesList.forEach(function (file, index) { @@ -96,7 +101,8 @@ define(function (require, exports, module) { do { var i, l = filePaths.length, - firstVal = filePaths[0][0]; + // || '' should prevent infinite loop as the other arrays will get undefined + firstVal = filePaths[0][0] || ''; for (i = 1; i < l; i++) { if (filePaths[i][0] !== firstVal) { foundDiff = true; From 693863e17bdaef414b82294d4064de28f4329852 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sat, 3 Aug 2013 01:03:59 +1000 Subject: [PATCH 08/15] Rewritten algorithm for finding unique directory path --- src/project/WorkingSetView.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 03a9dcd3ec8..5755e217980 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -89,13 +89,42 @@ define(function (require, exports, module) { } // First collect fullPaths from the list of files - var filePaths = []; + var filePaths = [], displayPaths = []; filesList.forEach(function (file, index) { var fp = file.fullPath.split('/'); fp.pop(); // Remove the filename itself + displayPaths[index] = fp.pop(); filePaths[index] = fp; }); + // Check if displayPaths are unique + var unique, i, j, l = displayPaths.length; + do { + unique = null; + for (i = 0; i < l; i++) { + for (j = i + 1; j < l; j++) { + if (displayPaths[i] === displayPaths[j]) { + unique = [i,j]; + } + } + } + if (unique !== null) { + // we got two indexes representing same displayPaths, one of them + // should add another parent directory into its display path + i = unique[0]; + j = unique[1]; + if (filePaths[i].length > filePaths[j].length) { + displayPaths[i] = filePaths[i].pop() + '/' + displayPaths[i]; + } else if (filePaths[i].length < filePaths[j].length) { + displayPaths[j] = filePaths[j].pop() + '/' + displayPaths[j]; + } else { + displayPaths[i] = filePaths[i].pop() + '/' + displayPaths[i]; + displayPaths[j] = filePaths[j].pop() + '/' + displayPaths[j]; + } + } + } while (unique !== null); + + /* // Then go through all the paths and shift them until a difference is found var foundDiff = false; do { @@ -115,6 +144,7 @@ define(function (require, exports, module) { } } } while (!foundDiff); + */ // Go through open files and add directories to appropriate entries $openFilesContainer.find("ul > li").each(function () { @@ -122,7 +152,7 @@ define(function (require, exports, module) { var file = $li.data(_FILE_KEY); var io = filesList.indexOf(file); if (io !== -1) { - var dirName = filePaths[io].join('/'); + var dirName = displayPaths[io]; var $dir = $("").html(" — " + dirName); $li.children("a").append($dir); } From bd793867f3a0c8273957352c17a52c3238407ed6 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sat, 3 Aug 2013 22:18:35 +1000 Subject: [PATCH 09/15] Another go on algorithm for finding unique directory path --- src/project/WorkingSetView.js | 87 ++++++++++++++--------------------- 1 file changed, 34 insertions(+), 53 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 5755e217980..06fd93ae315 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -88,72 +88,53 @@ define(function (require, exports, module) { return; } - // First collect fullPaths from the list of files - var filePaths = [], displayPaths = []; + // First collect paths from the list of files and fill map with them + var map = {}, filePaths = [], displayPaths = []; filesList.forEach(function (file, index) { var fp = file.fullPath.split('/'); fp.pop(); // Remove the filename itself displayPaths[index] = fp.pop(); filePaths[index] = fp; - }); - // Check if displayPaths are unique - var unique, i, j, l = displayPaths.length; - do { - unique = null; - for (i = 0; i < l; i++) { - for (j = i + 1; j < l; j++) { - if (displayPaths[i] === displayPaths[j]) { - unique = [i,j]; - } - } - } - if (unique !== null) { - // we got two indexes representing same displayPaths, one of them - // should add another parent directory into its display path - i = unique[0]; - j = unique[1]; - if (filePaths[i].length > filePaths[j].length) { - displayPaths[i] = filePaths[i].pop() + '/' + displayPaths[i]; - } else if (filePaths[i].length < filePaths[j].length) { - displayPaths[j] = filePaths[j].pop() + '/' + displayPaths[j]; - } else { - displayPaths[i] = filePaths[i].pop() + '/' + displayPaths[i]; - displayPaths[j] = filePaths[j].pop() + '/' + displayPaths[j]; - } - } - } while (unique !== null); - - /* - // Then go through all the paths and shift them until a difference is found - var foundDiff = false; - do { - var i, - l = filePaths.length, - // || '' should prevent infinite loop as the other arrays will get undefined - firstVal = filePaths[0][0] || ''; - for (i = 1; i < l; i++) { - if (filePaths[i][0] !== firstVal) { - foundDiff = true; - break; - } + if (!map[displayPaths[index]]) { + map[displayPaths[index]] = [index]; + } else { + map[displayPaths[index]].push(index); } - if (!foundDiff) { - for (i = 0; i < l; i++) { - filePaths[i].shift(); + }); + + // This function is used to loop through map and resolve duplicate names + var processMap = function (map) { + var didSomething = false; + CollectionUtils.forEach(map, function(arr, key) { + // length > 1 means we have duplicates that need to be resolved + if (arr.length > 1) { + arr.forEach(function(index) { + if (filePaths[index].length === 0) { return; } + displayPaths[index] = filePaths[index].pop() + '/' + displayPaths[index]; + didSomething = true; + + if (!map[displayPaths[index]]) { + map[displayPaths[index]] = [index]; + } else { + map[displayPaths[index]].push(index); + } + }); + map[key] = []; } - } - } while (!foundDiff); - */ + }); + return didSomething; + }; + + var repeat; + do { repeat = processMap(map); } while (repeat); // Go through open files and add directories to appropriate entries $openFilesContainer.find("ul > li").each(function () { var $li = $(this); - var file = $li.data(_FILE_KEY); - var io = filesList.indexOf(file); + var io = filesList.indexOf($li.data(_FILE_KEY)); if (io !== -1) { - var dirName = displayPaths[io]; - var $dir = $("").html(" — " + dirName); + var $dir = $("").html(" — " + displayPaths[io]); $li.children("a").append($dir); } }); From fd90174f760453addf1f029bc7bba6db22db8948 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 08:30:49 +1000 Subject: [PATCH 10/15] Fixed JSLint errors and code formatting. --- src/project/WorkingSetView.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 06fd93ae315..3fb0c4f80d5 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -106,28 +106,31 @@ define(function (require, exports, module) { // This function is used to loop through map and resolve duplicate names var processMap = function (map) { var didSomething = false; - CollectionUtils.forEach(map, function(arr, key) { + CollectionUtils.forEach(map, function (arr, key) { // length > 1 means we have duplicates that need to be resolved if (arr.length > 1) { - arr.forEach(function(index) { - if (filePaths[index].length === 0) { return; } - displayPaths[index] = filePaths[index].pop() + '/' + displayPaths[index]; - didSomething = true; - - if (!map[displayPaths[index]]) { - map[displayPaths[index]] = [index]; - } else { - map[displayPaths[index]].push(index); + arr.forEach(function (index) { + if (filePaths[index].length !== 0) { + displayPaths[index] = filePaths[index].pop() + '/' + displayPaths[index]; + didSomething = true; + + if (!map[displayPaths[index]]) { + map[displayPaths[index]] = [index]; + } else { + map[displayPaths[index]].push(index); + } } }); - map[key] = []; } + delete map[key]; }); return didSomething; }; var repeat; - do { repeat = processMap(map); } while (repeat); + do { + repeat = processMap(map); + } while (repeat); // Go through open files and add directories to appropriate entries $openFilesContainer.find("ul > li").each(function () { From 76fbcac9469872a7a4e7aa822deed576d2fb9196 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 08:38:12 +1000 Subject: [PATCH 11/15] Fixed a case where there are more than 3 folders to display. --- src/project/WorkingSetView.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 3fb0c4f80d5..0968cf320bd 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -137,6 +137,11 @@ define(function (require, exports, module) { var $li = $(this); var io = filesList.indexOf($li.data(_FILE_KEY)); if (io !== -1) { + var dirSplit = displayPaths[io].split('/'); + if (dirSplit.length > 3) { + displayPaths[io] = dirSplit[0] + '/.../' + dirSplit[dirSplit.length - 1]; + } + var $dir = $("").html(" — " + displayPaths[io]); $li.children("a").append($dir); } From a0e9923dabb81563511966412f562fdeb53b6dea Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 09:32:39 +1000 Subject: [PATCH 12/15] Fixed previous merge. --- src/extensions/default/JSLint/thirdparty/jslint | 1 + src/extensions/default/JavaScriptCodeHints/thirdparty/acorn | 2 +- src/extensions/default/JavaScriptCodeHints/thirdparty/tern | 2 +- src/thirdparty/CodeMirror2 | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 160000 src/extensions/default/JSLint/thirdparty/jslint diff --git a/src/extensions/default/JSLint/thirdparty/jslint b/src/extensions/default/JSLint/thirdparty/jslint new file mode 160000 index 00000000000..2347ec449b1 --- /dev/null +++ b/src/extensions/default/JSLint/thirdparty/jslint @@ -0,0 +1 @@ +Subproject commit 2347ec449b14eb3a4935daeaaa3ef036d42dd96d diff --git a/src/extensions/default/JavaScriptCodeHints/thirdparty/acorn b/src/extensions/default/JavaScriptCodeHints/thirdparty/acorn index d2673d465a7..9acedbc3d14 160000 --- a/src/extensions/default/JavaScriptCodeHints/thirdparty/acorn +++ b/src/extensions/default/JavaScriptCodeHints/thirdparty/acorn @@ -1 +1 @@ -Subproject commit d2673d465a794fdb4331dce1b88490fc5423b732 +Subproject commit 9acedbc3d14f0020e4dfb3bfe598d90dc305e6fc diff --git a/src/extensions/default/JavaScriptCodeHints/thirdparty/tern b/src/extensions/default/JavaScriptCodeHints/thirdparty/tern index 72b26679a91..fb2bb83134c 160000 --- a/src/extensions/default/JavaScriptCodeHints/thirdparty/tern +++ b/src/extensions/default/JavaScriptCodeHints/thirdparty/tern @@ -1 +1 @@ -Subproject commit 72b26679a91f0331eb83467c9becd086780d09e6 +Subproject commit fb2bb83134c1a1dec46459da7d22189974ea1ec5 diff --git a/src/thirdparty/CodeMirror2 b/src/thirdparty/CodeMirror2 index c921c10de61..88a03e386df 160000 --- a/src/thirdparty/CodeMirror2 +++ b/src/thirdparty/CodeMirror2 @@ -1 +1 @@ -Subproject commit c921c10de61a733a55015b5607f1c360baf2e285 +Subproject commit 88a03e386df2e3fe5f89238cff9ae763db41cdf6 From f7778b7ea6751ead8dac01d35f0e4f6dad82e0bc Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 10:52:53 +1000 Subject: [PATCH 13/15] Fixed usage of single quotes in code. --- src/project/WorkingSetView.js | 8 ++++---- test/spec/WorkingSetView-test.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index ca06efea4d9..db3ce64cb3a 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -103,7 +103,7 @@ define(function (require, exports, module) { // First collect paths from the list of files and fill map with them var map = {}, filePaths = [], displayPaths = []; filesList.forEach(function (file, index) { - var fp = file.fullPath.split('/'); + var fp = file.fullPath.split("/"); fp.pop(); // Remove the filename itself displayPaths[index] = fp.pop(); filePaths[index] = fp; @@ -123,7 +123,7 @@ define(function (require, exports, module) { if (arr.length > 1) { arr.forEach(function (index) { if (filePaths[index].length !== 0) { - displayPaths[index] = filePaths[index].pop() + '/' + displayPaths[index]; + displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index]; didSomething = true; if (!map[displayPaths[index]]) { @@ -149,9 +149,9 @@ define(function (require, exports, module) { var $li = $(this); var io = filesList.indexOf($li.data(_FILE_KEY)); if (io !== -1) { - var dirSplit = displayPaths[io].split('/'); + var dirSplit = displayPaths[io].split("/"); if (dirSplit.length > 3) { - displayPaths[io] = dirSplit[0] + '/.../' + dirSplit[dirSplit.length - 1]; + displayPaths[io] = dirSplit[0] + "/\u2026/" + dirSplit[dirSplit.length - 1]; } var $dir = $("").html(" — " + displayPaths[io]); diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index 7671ea7553f..abfeeb33466 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -147,7 +147,7 @@ define(function (require, exports, module) { runs(function () { var $ = testWindow.$; var secondItem = $($("#open-files-container > ul").children()[1]); - secondItem.trigger('click'); + secondItem.trigger("click"); var $listItems = $("#open-files-container > ul").children(); expect($($listItems[0]).hasClass("selected")).not.toBeTruthy(); @@ -215,7 +215,7 @@ define(function (require, exports, module) { // hover over and click on close icon of 2nd list item var secondItem = $($("#open-files-container > ul").children()[1]); - secondItem.trigger('mouseover'); + secondItem.trigger("mouseover"); var closeIcon = secondItem.find(".file-status-icon"); expect(closeIcon.length).toBe(1); @@ -224,7 +224,7 @@ define(function (require, exports, module) { didClose = true; }); - closeIcon.trigger('mousedown'); + closeIcon.trigger("mousedown"); }); waitsFor(function () { return didClose; }, "click on working set close icon timeout", 1000); @@ -253,7 +253,7 @@ define(function (require, exports, module) { var $ = testWindow.$; var secondItem = $("#open-files-container > ul").children().eq(1); var fileName = secondItem.text(); - secondItem.trigger('click'); + secondItem.trigger("click"); // Calling FILE_RENAME synchronously works fine here since the item is already visible in project file tree. // However, if the selected item is not already visible in the tree, this command will complete asynchronously. From d2cc6bb042178f0c738eead914a692ef73982d0e Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 11:42:35 +1000 Subject: [PATCH 14/15] Fixed JSLint errors in test file and addressed comments in pull request. --- src/project/WorkingSetView.js | 26 +++++++++++--------------- test/spec/WorkingSetView-test.js | 10 +++++----- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index db3ce64cb3a..5c54c80d657 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -90,9 +90,9 @@ define(function (require, exports, module) { } /** - * Adds directory names to elements representing passed files in working tree * @private - * @param {Array.} fileArray + * Adds directory names to elements representing passed files in working tree + * @param {Array.} filesList - list of FileEntries with the same filename */ function _addDirectoryNamesToWorkingTreeFiles(filesList) { // filesList must have at least two files in it for this to make sense @@ -161,35 +161,31 @@ define(function (require, exports, module) { } /** + * @private * Looks for files with the same name in the working set * and adds a parent directory name to them - * @private */ function _checkForDuplicatesInWorkingTree() { var map = {}, fileList = DocumentManager.getWorkingSet(); - // we need to always clear current directories as files could be removed from working tree + // We need to always clear current directories as files could be removed from working tree. $openFilesContainer.find("ul > li > a > span.directory").remove(); - // go through files and fill map with arrays of duplicates + // Go through files and fill map with arrays of files. fileList.forEach(function (file) { - // use the same function that is used to create html for file + // Use the same function that is used to create html for file. var displayHtml = ViewUtils.getFileEntryDisplay(file); - if (map[displayHtml] === undefined) { - map[displayHtml] = file; - } else { - if (!(map[displayHtml] instanceof Array)) { - map[displayHtml] = [map[displayHtml]]; - } - map[displayHtml].push(file); + if (!map[displayHtml]) { + map[displayHtml] = []; } + map[displayHtml].push(file); }); - // go through map and solve arrays, ignore rest + // Go through the map and solve the arrays with length over 1. Ignore the rest. CollectionUtils.forEach(map, function (value) { - if (value instanceof Array) { + if (value.length > 1) { _addDirectoryNamesToWorkingTreeFiles(value); } }); diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index abfeeb33466..66e55dd8332 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -41,7 +41,7 @@ define(function (require, exports, module) { var testPath = SpecRunnerUtils.getTestPath("/spec/WorkingSetView-test-files"), testWindow, - workingSetCount; + workingSetCount; function openAndMakeDirty(path) { var doc, didOpen = false, gotError = false; @@ -267,7 +267,7 @@ define(function (require, exports, module) { }); it("should show a directory name next to the file name when two files with same names are opened", function () { - runs(function() { + runs(function () { // Count currently opened files var workingSetCountBeforeTest = workingSetCount; @@ -277,7 +277,7 @@ define(function (require, exports, module) { // Wait for file to be added to the working set waitsFor(function () { return workingSetCount === workingSetCountBeforeTest + 1; }, 1000); - runs(function() { + runs(function () { // Two files with the same name file_one.js should be now opened var $list = testWindow.$("#open-files-container > ul"); expect($list.find(".directory").length).toBe(2); @@ -310,7 +310,7 @@ define(function (require, exports, module) { // Wait for them to load waitsFor(function () { return workingSetCount === workingSetCountBeforeTest + 2; }, 1000); - runs(function() { + runs(function () { // Collect all directory names displayed var $list = testWindow.$("#open-files-container > ul"); var names = $list.find(".directory").map(function () { @@ -319,7 +319,7 @@ define(function (require, exports, module) { // All directory names should be unique var uniq = 0, map = {}; - names.forEach(function(name) { + names.forEach(function (name) { if (!map[name]) { map[name] = true; uniq++; From da50ad08ca818561a28d9964157eb5d3c2bde4fe Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Sun, 4 Aug 2013 11:46:42 +1000 Subject: [PATCH 15/15] Used waitsForDone function in test instead of waitsFor. --- test/spec/WorkingSetView-test.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index 66e55dd8332..9a583aa7124 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -23,7 +23,7 @@ /*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */ -/*global $, define, describe, it, expect, beforeEach, afterEach, waitsFor, runs, beforeFirst, afterLast */ +/*global $, define, describe, it, expect, beforeEach, afterEach, waitsFor, waitsForDone, runs, beforeFirst, afterLast */ define(function (require, exports, module) { "use strict"; @@ -285,10 +285,7 @@ define(function (require, exports, module) { // Now close last opened file to hide the directories again DocumentManager.getCurrentDocument()._markClean(); // so we can close without a save dialog var didClose = false, gotError = false; - CommandManager.execute(Commands.FILE_CLOSE) - .done(function () { didClose = true; }) - .fail(function () { gotError = true; }); - waitsFor(function () { return didClose && !gotError; }, "timeout on FILE_CLOSE", 1000); + waitsForDone(CommandManager.execute(Commands.FILE_CLOSE), "timeout on FILE_CLOSE", 1000); // there should be no more directories shown runs(function () {