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 added to default extensions directory. #4590
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d36c1e9
"close others" extension.
sathyamoorthi 01c33fb
file close functions to handle list of files.
sathyamoorthi e8fae97
naming convention changes
sathyamoorthi 540e140
Merge branch 'master' into closeOthers2
sathyamoorthi 9e412f0
removeFromWrokingSet() changed to handle array of files.
sathyamoorthi 0bccd24
Merge branch 'master' into closeOthers2
sathyamoorthi a288ce1
Unit test added for close others
sathyamoorthi 9086c1d
jsHint fixes
sathyamoorthi 5f2c809
unnittest-files folder added.
sathyamoorthi 024b654
Merge branch 'master' into closeOthers2
sathyamoorthi 841a923
Merge branch 'master' into closeOthers2
sathyamoorthi 967738e
Merge branch 'master' into closeOthers2
sathyamoorthi bd4018d
Integration test failures fixed
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window, document */ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var Menus = brackets.getModule("command/Menus"), | ||
CommandManager = brackets.getModule("command/CommandManager"), | ||
Commands = brackets.getModule("command/Commands"), | ||
dm = brackets.getModule("document/DocumentManager"), | ||
docCH = brackets.getModule("document/DocumentCommandHandlers"), | ||
strings = brackets.getModule("i18n!nls/strings"), | ||
settings = JSON.parse(require("text!settings.json")), | ||
working_set_cmenu = Menus.getContextMenu(Menus.ContextMenuIds.WORKING_SET_MENU), | ||
close_others = "file.close_others", | ||
close_above = "file.close_above", | ||
close_below = "file.close_below"; | ||
|
||
function handleClose(mode) { | ||
|
||
var targetIndex = dm.findInWorkingSet(dm.getCurrentDocument().file.fullPath), | ||
workingSet = dm.getWorkingSet().slice(0), | ||
start = (mode === close_below) ? (targetIndex + 1) : 0, | ||
end = (mode === close_above) ? (targetIndex) : (workingSet.length), | ||
docList = [], | ||
i; | ||
|
||
if (mode === close_others) { | ||
end--; | ||
workingSet.splice(targetIndex, 1); | ||
} | ||
|
||
for (i = start; i < end; i++) { | ||
docList.push(workingSet[i]); | ||
} | ||
|
||
CommandManager.execute(Commands.FILE_CLOSE_LIST, {documentList: docList}); | ||
} | ||
|
||
if (settings.close_below) { | ||
CommandManager.register(strings.CMD_FILE_CLOSE_BELOW, close_below, function () { | ||
handleClose(close_below); | ||
}); | ||
working_set_cmenu.addMenuItem(close_below, "", Menus.AFTER, Commands.FILE_CLOSE); | ||
} | ||
|
||
if (settings.close_others) { | ||
CommandManager.register(strings.CMD_FILE_CLOSE_OTHERS, close_others, function () { | ||
handleClose(close_others); | ||
}); | ||
working_set_cmenu.addMenuItem(close_others, "", Menus.AFTER, Commands.FILE_CLOSE); | ||
} | ||
|
||
if (settings.close_above) { | ||
CommandManager.register(strings.CMD_FILE_CLOSE_ABOVE, close_above, function () { | ||
handleClose(close_above); | ||
}); | ||
working_set_cmenu.addMenuItem(close_above, "", Menus.AFTER, Commands.FILE_CLOSE); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"close_others": true, | ||
"close_above": true, | ||
"close_below": true | ||
} | ||
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
//This is dummy file. To commit unnittest-files folder git needs a file. |
Oops, something went wrong.
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 Shall we enable only "close others"? Because, it would annoy users by showing other two (close_above and close_below) all the time. If i once know how to add and remove menus dynamically we can add them. what do you think?
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.
Yep, I say show them. If it becomes a problem we can easily turn it off
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.
Yes. consider if there is only one file in the working set, it will still show "Close Others", "Close Others Above" and "Close Others Below". So i should work next to add and remove menus intelligently based user click. So if you wish, i can down those two flags and give pull request for now.
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.
I considered it and the convention is to disable the menu items which we have a story for and we will be working soon. So leave them enabled for now and then we'll have to fix it so they are disabled when the first/last item are selected 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.
we have many menu items that are enabled when they shouldn't be so we are aware of the problem.
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.
oh. that's cool. just making sure you know this nit. then, no problem. let me do those small change and give PR.