This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Close Others extension improvements. #5497
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eaa593b
'clearCurrentDoc' flag added to '_doCloseDocumentList'
sathyamoorthi 7ff5efa
unit test file update
sathyamoorthi 913cabc
Add / remove context menus at run time.
sathyamoorthi 05e41ef
jsHint fixes.
sathyamoorthi d0fa2db
replace `jQuery` with `$` for coding standard.
sathyamoorthi 83d603c
Code changes proposed by Jeff and Ian
sathyamoorthi e1efd6d
Tab alignments corrected.
sathyamoorthi fbdd877
Test file updated to match standards.
sathyamoorthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ define(function (require, exports, module) { | |
FileUtils = brackets.getModule("file/FileUtils"), | ||
CommandManager, | ||
Commands, | ||
Dialogs, | ||
EditorManager, | ||
Menus, | ||
DocumentManager; | ||
|
||
describe("CloseOthers", function () { | ||
|
@@ -86,9 +85,8 @@ define(function (require, exports, module) { | |
brackets = testWindow.brackets; | ||
DocumentManager = testWindow.brackets.test.DocumentManager; | ||
CommandManager = testWindow.brackets.test.CommandManager; | ||
EditorManager = testWindow.brackets.test.EditorManager; | ||
Dialogs = testWindow.brackets.test.Dialogs; | ||
Commands = testWindow.brackets.test.Commands; | ||
Commands = testWindow.brackets.test.Commands; | ||
Menus = testWindow.brackets.test.Menus; | ||
}); | ||
}); | ||
|
||
|
@@ -119,42 +117,58 @@ define(function (require, exports, module) { | |
testWindow = null; | ||
$ = null; | ||
brackets = null; | ||
EditorManager = null; | ||
SpecRunnerUtils.closeTestWindow(); | ||
}); | ||
|
||
|
||
function runCloseOthers() { | ||
var ws = DocumentManager.getWorkingSet(), | ||
cm = Menus.getContextMenu(Menus.ContextMenuIds.WORKING_SET_MENU), | ||
promise; | ||
|
||
if (ws.length > docSelectIndex) { | ||
DocumentManager.getDocumentForPath(ws[docSelectIndex].fullPath).done(function (doc) { | ||
DocumentManager.setCurrentDocument(doc); | ||
|
||
/* | ||
"Close Others" extension removes unnecessary menus AND add necessary menus on workingset by listening | ||
`beforeContextMenuOpen` event. For that, we have to open workinget's context menu. Then only this extension | ||
will populate necessary context menu items. | ||
|
||
`pageX` and `pageY` can be any number. our only intention is to open context menu. but it can open at anywhere. | ||
*/ | ||
cm.open({pageX: 0, pageY: 0}); | ||
}); | ||
|
||
promise = CommandManager.execute(cmdToRun); | ||
waitsForDone(promise, cmdToRun); | ||
} | ||
|
||
runs(function () { | ||
expect(DocumentManager.getCurrentDocument()).not.toBe(null); | ||
}); | ||
} | ||
|
||
it("Close others", function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you fix the tabs in this block. lines 156-159 are misaligned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is funny issue. It looked good in Brackets and Submlime but not in github. I deleted and recreated those lines to fix this. |
||
docSelectIndex = 2; | ||
cmdToRun = "file.close_others"; | ||
|
||
runs(runCloseOthers); | ||
|
||
runs(function () { | ||
expect(DocumentManager.getWorkingSet().length).toEqual(1); | ||
}); | ||
|
||
//we created 5 files and selected 3rd file (index = 2), then we ran "close others". | ||
//At this point we should have only one file in working set. | ||
runs(function () { | ||
expect(DocumentManager.getWorkingSet().length).toEqual(1); | ||
}); | ||
}); | ||
|
||
it("Close others above", function () { | ||
docSelectIndex = 2; | ||
cmdToRun = "file.close_above"; | ||
|
||
runs(runCloseOthers); | ||
|
||
|
||
//we created 5 files and selected 3rd file (index = 2), then we ran "close others above". | ||
//At this point we should have only 3 files in working set. | ||
runs(function () { | ||
expect(DocumentManager.getWorkingSet().length).toEqual(3); | ||
}); | ||
|
@@ -166,6 +180,8 @@ define(function (require, exports, module) { | |
|
||
runs(runCloseOthers); | ||
|
||
//we created 5 files and selected 2nd file (index = 1), then we ran "close others below". | ||
//At this point we should have only 2 files in working set. | ||
runs(function () { | ||
expect(DocumentManager.getWorkingSet().length).toEqual(2); | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeffryBooher @redmunds. I replaced triggering
contextmenu
event withcontextmenu.open
. Hope you may like it this time.